Class: Nanite::ActorRegistry
Instance Attribute Summary collapse
-
#actors ⇒ Object
readonly
Returns the value of attribute actors.
Instance Method Summary collapse
- #actor_for(prefix) ⇒ Object
-
#initialize ⇒ ActorRegistry
constructor
A new instance of ActorRegistry.
- #register(actor, prefix) ⇒ Object
- #services ⇒ Object
Constructor Details
#initialize ⇒ ActorRegistry
Returns a new instance of ActorRegistry.
5 6 7 |
# File 'lib/nanite/actor_registry.rb', line 5 def initialize @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 |
Instance Method Details
#actor_for(prefix) ⇒ Object
22 23 24 |
# File 'lib/nanite/actor_registry.rb', line 22 def actor_for(prefix) actor = actors[prefix] end |
#register(actor, prefix) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/nanite/actor_registry.rb', line 9 def register(actor, prefix) raise ArgumentError, "#{actor.inspect} is not a Nanite::Actor subclass instance" unless Nanite::Actor === actor log_msg = "[actor] #{actor.class.to_s}" log_msg += ", prefix #{prefix}" if prefix && !prefix.empty? Nanite::Log.info(log_msg) prefix ||= actor.class.default_prefix actors[prefix.to_s] = actor end |
#services ⇒ Object
18 19 20 |
# File 'lib/nanite/actor_registry.rb', line 18 def services actors.map {|prefix, actor| actor.class.provides_for(prefix) }.flatten.uniq end |