Class: Racket::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/registry.rb

Overview

Racket Registry namespace

Defined Under Namespace

Classes: InvalidCallbackError, InvalidKeyError, KeyAlreadyRegisteredError, KeyNotRegisteredError

Instance Method Summary collapse

Instance Method Details

#forget(key) ⇒ nil

Removes the callback specified by key from the registry.

Parameters:

  • key (String|Symbol)

Returns:

  • (nil)


27
28
29
# File 'lib/racket/registry.rb', line 27

def forget(key)
  Helper.forget(obj: self, key: key)
end

#forget_allObject

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.

Parameters:

  • key (String|Symbol)
  • proc (Proc|nil) (defaults to: nil)

Returns:

  • (nil)


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.

Parameters:

  • key (String|Symbol)
  • proc (Proc|nil) (defaults to: nil)

Returns:

  • (nil)


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