class Swarm::Hive
Attributes
storage[R]
work_queue[R]
Public Class Methods
default()
click to toggle source
# File lib/swarm/hive.rb, line 15 def default unless @default raise NoDefaultSetError.new("No default Hive defined yet") end @default end
default=(default)
click to toggle source
# File lib/swarm/hive.rb, line 8 def default=(default) unless default.is_a?(self) raise IllegalDefaultError.new("Default must be a Swarm::Hive") end @default = default end
new(storage:, work_queue:)
click to toggle source
# File lib/swarm/hive.rb, line 25 def initialize(storage:, work_queue:) @storage = storage @work_queue = work_queue end
Public Instance Methods
fetch(klass, id)
click to toggle source
# File lib/swarm/hive.rb, line 57 def fetch(klass, id) Swarm::Support.constantize(klass).fetch(id, hive: self) end
inspect()
click to toggle source
# File lib/swarm/hive.rb, line 34 def inspect "#<Swarm::Hive storage: #{storage_class}, work_queue: #{work_queue.name}>" end
queue(action, object)
click to toggle source
# File lib/swarm/hive.rb, line 50 def queue(action, object) @work_queue.add_job({ :action => action, :metadata => object.to_hash }) end
registered_observers()
click to toggle source
# File lib/swarm/hive.rb, line 30 def registered_observers @registered_observers ||= [] end
reify_from_hash(hsh)
click to toggle source
# File lib/swarm/hive.rb, line 61 def reify_from_hash(hsh) Support.symbolize_keys!(hsh) raise MissingTypeError.new(hsh.inspect) unless hsh[:type] Swarm::Support.constantize(hsh.delete(:type)).new_from_storage( hsh.merge( :hive => self ) ) end
storage_class()
click to toggle source
# File lib/swarm/hive.rb, line 38 def storage_class storage.class.name.split('::').last end
trace(new_element)
click to toggle source
# File lib/swarm/hive.rb, line 46 def trace(new_element) storage.trace = traced + [new_element] end
traced()
click to toggle source
# File lib/swarm/hive.rb, line 42 def traced storage.trace ||= [] end