Class: Dynflow::Coordinator::Lock

Inherits:
Record show all
Defined in:
lib/dynflow/coordinator.rb

Constant Summary

Constants inherited from Serializable

Serializable::LEGACY_TIME_FORMAT, Serializable::TIME_FORMAT

Instance Attribute Summary

Attributes inherited from Record

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#==, #from_hash, #hash, #id, #initialize, new_from_hash, #to_hash

Methods inherited from Serializable

from_hash, new_from_hash, #to_hash

Constructor Details

This class inherits a constructor from Dynflow::Coordinator::Record

Class Method Details

.constantize(name) ⇒ Object



126
127
128
129
130
131
# File 'lib/dynflow/coordinator.rb', line 126

def self.constantize(name)
  Serializable.constantize(name)
rescue NameError
  # If we don't find the lock name, return the most generic version
  Lock
end

Instance Method Details

#owner_idObject



137
138
139
# File 'lib/dynflow/coordinator.rb', line 137

def owner_id
  @data[:owner_id]
end

#to_sObject



133
134
135
# File 'lib/dynflow/coordinator.rb', line 133

def to_s
  "#{self.class.name}: #{id} by #{owner_id}"
end

#unlock_on_shutdown?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'lib/dynflow/coordinator.rb', line 149

def unlock_on_shutdown?
  true
end

#validate!Object

check to be performed before we try to acquire the lock



143
144
145
146
147
# File 'lib/dynflow/coordinator.rb', line 143

def validate!
  super
  raise "Can't acquire the lock after deserialization" if @from_hash
  Type! owner_id, String
end