class Dynflow::Coordinator::Record

Attributes

data[R]

Public Class Methods

constantize(name) click to toggle source
# File lib/dynflow/coordinator.rb, line 35
def self.constantize(name)
  Serializable.constantize(name)
rescue NameError
  # If we don't find the lock name, return the most generic version
  Record
end
new(*args) click to toggle source
# File lib/dynflow/coordinator.rb, line 42
def initialize(*args)
  @data ||= {}
  @data = Utils.indifferent_hash(@data.merge(class: self.class.name))
end
new_from_hash(hash) click to toggle source
# File lib/dynflow/coordinator.rb, line 31
def self.new_from_hash(hash)
  self.allocate.tap { |record| record.from_hash(hash) }
end

Public Instance Methods

==(other_object) click to toggle source
# File lib/dynflow/coordinator.rb, line 73
def ==(other_object)
  self.class == other_object.class && self.id == other_object.id
end
from_hash(hash) click to toggle source
# File lib/dynflow/coordinator.rb, line 47
def from_hash(hash)
  @data      = hash
  @from_hash = true
end
hash() click to toggle source
# File lib/dynflow/coordinator.rb, line 77
def hash
  [self.class, self.id].hash
end
id() click to toggle source
# File lib/dynflow/coordinator.rb, line 56
def id
  @data[:id]
end
to_hash() click to toggle source
# File lib/dynflow/coordinator.rb, line 52
def to_hash
  @data
end
to_s() click to toggle source
# File lib/dynflow/coordinator.rb, line 69
def to_s
  "#{self.class.name}: #{id}"
end
validate!() click to toggle source

@api override check to be performed before we try to acquire the lock

# File lib/dynflow/coordinator.rb, line 62
def validate!
  Type! id,       String
  Type! @data,     Hash
  raise "The record id %{s} too large" % id if id.size > 100
  raise "The record class name %{s} too large" % self.class.name if self.class.name.size > 100
end