Class: Thoreau::Model::Appendix
- Inherits:
-
Object
- Object
- Thoreau::Model::Appendix
- Defined in:
- lib/thoreau/model/appendix.rb
Instance Attribute Summary collapse
-
#setups ⇒ Object
readonly
Returns the value of attribute setups.
Instance Method Summary collapse
- #add_setup(setup) ⇒ Object
-
#initialize(setups: {}) ⇒ Appendix
constructor
A new instance of Appendix.
- #setup_values(keys) ⇒ Object
Constructor Details
#initialize(setups: {}) ⇒ Appendix
Returns a new instance of Appendix.
7 8 9 |
# File 'lib/thoreau/model/appendix.rb', line 7 def initialize setups: {} @setups = setups end |
Instance Attribute Details
#setups ⇒ Object (readonly)
Returns the value of attribute setups.
5 6 7 |
# File 'lib/thoreau/model/appendix.rb', line 5 def setups @setups end |
Instance Method Details
#add_setup(setup) ⇒ Object
11 12 13 14 |
# File 'lib/thoreau/model/appendix.rb', line 11 def add_setup setup raise "Duplicate setup block #{setup.name}" unless setups[setup.name].nil? @setups[setup.name] = setup end |
#setup_values(keys) ⇒ Object
16 17 18 19 20 |
# File 'lib/thoreau/model/appendix.rb', line 16 def setup_values keys keys .map { |key| self.setup_key_to_inputs key } .reduce(Hash.new) { |m, h| m.merge(h) } end |