Class: InputStore

Inherits:
Object
  • Object
show all
Defined in:
lib/clingon/helpers/input_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInputStore

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

#inputsObject (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