Class: InputStore
- Inherits:
-
Object
- Object
- InputStore
- Defined in:
- lib/clingon/helpers/input_store.rb
Instance Attribute Summary collapse
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
Instance Method Summary collapse
- #fetch(value) ⇒ Object
-
#initialize ⇒ InputStore
constructor
A new instance of InputStore.
- #store(name, value) ⇒ Object
Constructor Details
#initialize ⇒ InputStore
Returns a new instance of InputStore.
3 4 5 |
# File 'lib/clingon/helpers/input_store.rb', line 3 def initialize @inputs = [] end |
Instance Attribute Details
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
2 3 4 |
# File 'lib/clingon/helpers/input_store.rb', line 2 def inputs @inputs end |
Instance Method Details
#fetch(value) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/clingon/helpers/input_store.rb', line 14 def fetch(value) inputs.inject(nil) do |val, current| if current[:name] == value current else val end end end |
#store(name, value) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/clingon/helpers/input_store.rb', line 7 def store(name, value) @inputs << { name: name, value: value } end |