Class: Racket::Registry
- Inherits:
-
Object
- Object
- Racket::Registry
- Defined in:
- lib/racket/registry.rb
Overview
Racket Registry namespace
Defined Under Namespace
Classes: InvalidCallbackError, InvalidKeyError, KeyAlreadyRegisteredError, KeyNotRegisteredError
Instance Method Summary collapse
-
#forget(key) ⇒ nil
Removes the callback specified by
keyfrom the registry. -
#forget_all ⇒ Object
Removes all callbacks from the registry.
-
#register(key, proc = nil, &block) ⇒ nil
Registers a new callback in the registry.
-
#register_singleton(key, proc = nil, &block) ⇒ nil
(also: #singleton)
Registers a new callback in the registry.
Instance Method Details
#forget(key) ⇒ nil
Removes the callback specified by key from the registry.
27 28 29 |
# File 'lib/racket/registry.rb', line 27 def forget(key) Helper.forget(obj: self, key: key) end |
#forget_all ⇒ Object
Removes all callbacks from the registry.
32 33 34 |
# File 'lib/racket/registry.rb', line 32 def forget_all Helper.forget_all(obj: self) end |
#register(key, proc = nil, &block) ⇒ nil
Registers a new callback in the registry. This will add a new method matching key to the registry that can be used both outside the registry and when registering other callbacks dependant of the current entry. Results from the callback will not be cached, meaning that the callback may return a different object every time.
45 46 47 |
# File 'lib/racket/registry.rb', line 45 def register(key, proc = nil, &block) Helper.register(obj: self, key: key, proc: proc, block: block) end |
#register_singleton(key, proc = nil, &block) ⇒ nil Also known as: singleton
Registers a new callback in the registry. This will add a new method matching key to the registry that can be used both outside the registry and when registering other callbacks dependant of the current entry. Results from the callnack will be cached, meaning that the callback will return the same object every time.
58 59 60 |
# File 'lib/racket/registry.rb', line 58 def register_singleton(key, proc = nil, &block) Helper.register_singleton(obj: self, key: key, proc: proc, block: block) end |