Class: Dynflow::Coordinator::LockByWorld

Inherits:
Lock 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 Lock

constantize, #owner_id, #to_s

Methods inherited from Record

#==, constantize, #from_hash, #hash, #id, new_from_hash, #to_hash, #to_s

Methods inherited from Serializable

constantize, from_hash, new_from_hash, #to_hash

Constructor Details

#initialize(world) ⇒ LockByWorld

Returns a new instance of LockByWorld.



151
152
153
154
155
# File 'lib/dynflow/coordinator.rb', line 151

def initialize(world)
  super
  @world = world
  @data.merge!(owner_id: "world:#{world.id}", world_id: world.id)
end

Class Method Details

.inherited(klass) ⇒ Object



182
183
184
# File 'lib/dynflow/coordinator.rb', line 182

def self.inherited(klass)
  valid_classes << klass
end

.lock_id(*args) ⇒ Object

Raises:

  • (NoMethodError)


157
158
159
# File 'lib/dynflow/coordinator.rb', line 157

def self.lock_id(*args)
  raise NoMethodError
end

.unique_filter(*args) ⇒ Object



161
162
163
# File 'lib/dynflow/coordinator.rb', line 161

def self.unique_filter(*args)
  { :class => self.name, :id => lock_id(*args) }
end

.valid_classesObject



178
179
180
# File 'lib/dynflow/coordinator.rb', line 178

def self.valid_classes
  @valid_classes ||= []
end

.valid_owner_ids(coordinator) ⇒ Object



174
175
176
# File 'lib/dynflow/coordinator.rb', line 174

def self.valid_owner_ids(coordinator)
  coordinator.find_worlds.map { |w| "world:#{w.id}" }
end

Instance Method Details

#validate!Object



165
166
167
168
# File 'lib/dynflow/coordinator.rb', line 165

def validate!
  super
  raise Errors::InactiveWorldError.new(@world) if @world.terminating?
end

#world_idObject



170
171
172
# File 'lib/dynflow/coordinator.rb', line 170

def world_id
  @data[:world_id]
end