Class: Nanite::ActorRegistry
Instance Attribute Summary collapse
-
#actors ⇒ Object
readonly
Returns the value of attribute actors.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
Instance Method Summary collapse
- #actor_for(prefix) ⇒ Object
-
#initialize(log) ⇒ ActorRegistry
constructor
A new instance of ActorRegistry.
- #register(actor, prefix) ⇒ Object
- #services ⇒ Object
Constructor Details
#initialize(log) ⇒ ActorRegistry
Returns a new instance of ActorRegistry.
5 6 7 8 |
# File 'lib/nanite/actor_registry.rb', line 5 def initialize(log) @log = log @actors = {} end |
Instance Attribute Details
#actors ⇒ Object (readonly)
Returns the value of attribute actors.
3 4 5 |
# File 'lib/nanite/actor_registry.rb', line 3 def actors @actors end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
3 4 5 |
# File 'lib/nanite/actor_registry.rb', line 3 def log @log end |
Instance Method Details
#actor_for(prefix) ⇒ Object
21 22 23 |
# File 'lib/nanite/actor_registry.rb', line 21 def actor_for(prefix) actor = actors[prefix] end |
#register(actor, prefix) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/nanite/actor_registry.rb', line 10 def register(actor, prefix) raise ArgumentError, "#{actor.inspect} is not a Nanite::Actor subclass instance" unless Nanite::Actor === actor log.info("Registering #{actor.inspect} with prefix #{prefix.inspect}") prefix ||= actor.class.default_prefix actors[prefix.to_s] = actor end |
#services ⇒ Object
17 18 19 |
# File 'lib/nanite/actor_registry.rb', line 17 def services actors.map {|prefix, actor| actor.class.provides_for(prefix) }.flatten.uniq end |