Class: Danica::VariablesHolder::Store
- Inherits:
-
Object
- Object
- Danica::VariablesHolder::Store
- Defined in:
- lib/danica/variables_holder/store.rb
Instance Attribute Summary collapse
-
#default_variables_hash ⇒ Object
readonly
Returns the value of attribute default_variables_hash.
-
#variables_names ⇒ Object
readonly
Returns the value of attribute variables_names.
Instance Method Summary collapse
- #containers ⇒ Object
- #containers_hash ⇒ Object
- #extract_variables ⇒ Object
-
#initialize(default_variables_hash) ⇒ Store
constructor
A new instance of Store.
- #variables ⇒ Object
- #variables_hash ⇒ Object
- #variables_value_hash ⇒ Object
Constructor Details
#initialize(default_variables_hash) ⇒ Store
Returns a new instance of Store.
7 8 9 10 |
# File 'lib/danica/variables_holder/store.rb', line 7 def initialize(default_variables_hash) @default_variables_hash = default_variables_hash @variables_names = default_variables_hash.keys end |
Instance Attribute Details
#default_variables_hash ⇒ Object (readonly)
Returns the value of attribute default_variables_hash.
5 6 7 |
# File 'lib/danica/variables_holder/store.rb', line 5 def default_variables_hash @default_variables_hash end |
#variables_names ⇒ Object (readonly)
Returns the value of attribute variables_names.
5 6 7 |
# File 'lib/danica/variables_holder/store.rb', line 5 def variables_names @variables_names end |
Instance Method Details
#containers ⇒ Object
16 17 18 |
# File 'lib/danica/variables_holder/store.rb', line 16 def containers containers_hash.values end |
#containers_hash ⇒ Object
12 13 14 |
# File 'lib/danica/variables_holder/store.rb', line 12 def containers_hash @containers_hash ||= {}.merge(default_containers_hash) end |
#extract_variables ⇒ Object
34 35 36 |
# File 'lib/danica/variables_holder/store.rb', line 34 def extract_variables inner_containers_hash.merge(named_variables_hash) end |
#variables ⇒ Object
20 21 22 |
# File 'lib/danica/variables_holder/store.rb', line 20 def variables containers.map(&:content) end |
#variables_hash ⇒ Object
24 25 26 |
# File 'lib/danica/variables_holder/store.rb', line 24 def variables_hash containers_hash.change_values(&:content) end |
#variables_value_hash ⇒ Object
28 29 30 31 32 |
# File 'lib/danica/variables_holder/store.rb', line 28 def variables_value_hash variables.map do |var| var.try(:value) end.as_hash(variables_names) end |