Class: Draisine::Registry
- Inherits:
-
Object
- Object
- Draisine::Registry
- Defined in:
- lib/draisine/registry.rb
Instance Attribute Summary collapse
-
#models ⇒ Object
readonly
Returns the value of attribute models.
Instance Method Summary collapse
- #find(name) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #register(model, name) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
5 6 7 |
# File 'lib/draisine/registry.rb', line 5 def initialize @models = {} end |
Instance Attribute Details
#models ⇒ Object (readonly)
Returns the value of attribute models.
3 4 5 |
# File 'lib/draisine/registry.rb', line 3 def models @models end |
Instance Method Details
#find(name) ⇒ Object
9 10 11 |
# File 'lib/draisine/registry.rb', line 9 def find(name) models.fetch(name) end |
#register(model, name) ⇒ Object
13 14 15 16 |
# File 'lib/draisine/registry.rb', line 13 def register(model, name) models[name] = model models[model.name] ||= model end |