Class: SolidObjects::EffectRegistry
- Inherits:
-
Object
- Object
- SolidObjects::EffectRegistry
- Defined in:
- lib/solid_objects/effect_registry.rb,
sig/generated/lib/solid_objects/effect_registry.rbs
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
Instance Method Summary collapse
- #fetch(name) ⇒ Proc
-
#initialize ⇒ EffectRegistry
constructor
A new instance of EffectRegistry.
- #register(name, handler) ⇒ Proc
Constructor Details
#initialize ⇒ EffectRegistry
Returns a new instance of EffectRegistry.
9 10 11 12 |
# File 'lib/solid_objects/effect_registry.rb', line 9 def initialize @handlers = {} @mutex = Mutex.new end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
32 33 34 |
# File 'lib/solid_objects/effect_registry.rb', line 32 def handlers @handlers end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
32 33 34 |
# File 'lib/solid_objects/effect_registry.rb', line 32 def mutex @mutex end |
Instance Method Details
#fetch(name) ⇒ Proc
24 25 26 27 28 |
# File 'lib/solid_objects/effect_registry.rb', line 24 def fetch(name) handlers.fetch(name.to_s) do raise InvalidActor, "no effect handler registered for #{name.inspect}" end end |
#register(name, handler) ⇒ Proc
15 16 17 18 19 20 21 |
# File 'lib/solid_objects/effect_registry.rb', line 15 def register(name, handler) effect_name = name.to_s raise ArgumentError, "effect name cannot be empty" if effect_name.empty? mutex.synchronize { handlers[effect_name] = handler } handler end |