Class: GlueGun::Model::ServiceRegistry
- Inherits:
-
Object
- Object
- GlueGun::Model::ServiceRegistry
- Defined in:
- lib/glue_gun/model.rb
Instance Attribute Summary collapse
-
#services ⇒ Object
Returns the value of attribute services.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
- #default ⇒ Object
- #default_key ⇒ Object
- #options ⇒ Object
- #register(k, v) ⇒ Object
Instance Attribute Details
#services ⇒ Object
Returns the value of attribute services.
8 9 10 |
# File 'lib/glue_gun/model.rb', line 8 def services @services end |
Instance Method Details
#[](k) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/glue_gun/model.rb', line 23 def [](k) return nil if k.nil? @services ||= {} @services.dig(k.to_sym) end |
#[]=(k, v) ⇒ Object
19 20 21 |
# File 'lib/glue_gun/model.rb', line 19 def []=(k, v) register(k, v) end |
#default ⇒ Object
36 37 38 |
# File 'lib/glue_gun/model.rb', line 36 def default default_key.present? ? services[default_key] : nil end |
#default_key ⇒ Object
30 31 32 33 34 |
# File 'lib/glue_gun/model.rb', line 30 def default_key return unless services.keys.count == 1 services.keys.first end |
#options ⇒ Object
15 16 17 |
# File 'lib/glue_gun/model.rb', line 15 def services.keys end |
#register(k, v) ⇒ Object
10 11 12 13 |
# File 'lib/glue_gun/model.rb', line 10 def register(k, v) @services ||= {} @services[k.to_sym] = v end |