Class: Esse::DynamicTemplate
- Inherits:
-
Object
- Object
- Esse::DynamicTemplate
- Defined in:
- lib/esse/dynamic_template.rb
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- #any? ⇒ Boolean
- #dup ⇒ Object
-
#initialize(value) ⇒ DynamicTemplate
constructor
A new instance of DynamicTemplate.
- #merge!(value) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(value) ⇒ DynamicTemplate
Returns a new instance of DynamicTemplate.
6 7 8 |
# File 'lib/esse/dynamic_template.rb', line 6 def initialize(value) @hash = normalize(value) end |
Instance Method Details
#[]=(key, value) ⇒ Object
14 15 16 |
# File 'lib/esse/dynamic_template.rb', line 14 def []=(key, value) merge!(key => value) end |
#any? ⇒ Boolean
24 25 26 |
# File 'lib/esse/dynamic_template.rb', line 24 def any? @hash.any? end |
#dup ⇒ Object
28 29 30 |
# File 'lib/esse/dynamic_template.rb', line 28 def dup self.class.new(@hash.dup) end |
#merge!(value) ⇒ Object
10 11 12 |
# File 'lib/esse/dynamic_template.rb', line 10 def merge!(value) @hash = HashUtils.deep_merge(@hash, normalize(value)) end |
#to_a ⇒ Object
18 19 20 21 22 |
# File 'lib/esse/dynamic_template.rb', line 18 def to_a @hash.map do |name, value| { name => value } end end |