Module: PinballWizard::Registry
Instance Method Summary collapse
- #add(feature) ⇒ Object
- #clear ⇒ Object
- #collection ⇒ Object
- #disabled?(name) ⇒ Boolean
- #get(name) ⇒ Object
- #to_h ⇒ Object (also: #to_hash)
Instance Method Details
#add(feature) ⇒ Object
9 10 11 |
# File 'lib/pinball_wizard/registry.rb', line 9 def add(feature) collection[feature.name] = feature end |
#clear ⇒ Object
25 26 27 |
# File 'lib/pinball_wizard/registry.rb', line 25 def clear @collection = {} end |
#collection ⇒ Object
21 22 23 |
# File 'lib/pinball_wizard/registry.rb', line 21 def collection @collection ||= {} end |
#disabled?(name) ⇒ Boolean
17 18 19 |
# File 'lib/pinball_wizard/registry.rb', line 17 def disabled?(name) get(name).disabled? end |
#get(name) ⇒ Object
13 14 15 |
# File 'lib/pinball_wizard/registry.rb', line 13 def get(name) collection.fetch(name.to_s) { null_feature } end |
#to_h ⇒ Object Also known as: to_hash
29 30 31 32 33 34 |
# File 'lib/pinball_wizard/registry.rb', line 29 def to_h pairs = collection.map do |name, feature| [feature.to_s, feature.state] end ::Hash[pairs] end |