Class: BlockConfigurable::Configuration
- Inherits:
-
Object
- Object
- BlockConfigurable::Configuration
- Defined in:
- lib/block_configurable/configuration.rb
Instance Method Summary collapse
- #add_config(param, default = nil) ⇒ Object
- #to_h ⇒ Object (also: #to_hash)
Instance Method Details
#add_config(param, default = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/block_configurable/configuration.rb', line 3 def add_config(param, default = nil) instance_eval %Q{ def #{param} @#{param} end def #{param}=(value) @#{param} = value end } instance_variable_set "@#{param}", default end |
#to_h ⇒ Object Also known as: to_hash
17 18 19 20 21 |
# File 'lib/block_configurable/configuration.rb', line 17 def to_h instance_variables.reduce(Hash.new) do |a, e| a.merge(e[1..-1].to_sym => instance_variable_get(e)) end end |