Module: PinballWizard::Registry

Extended by:
Registry
Included in:
Registry
Defined in:
lib/pinball_wizard/registry.rb

Instance Method Summary collapse

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

#clearObject



25
26
27
# File 'lib/pinball_wizard/registry.rb', line 25

def clear
  @collection = {}
end

#collectionObject



21
22
23
# File 'lib/pinball_wizard/registry.rb', line 21

def collection
  @collection ||= {}
end

#disabled?(name) ⇒ Boolean

Returns:

  • (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_hObject 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