Class: Convection::Model::Template::Resource::HashPropertyInstance
- Inherits:
-
PropertyInstance
- Object
- PropertyInstance
- Convection::Model::Template::Resource::HashPropertyInstance
- Defined in:
- lib/convection/model/template/resource.rb
Overview
Instance of a hash property
Instance Attribute Summary
Attributes inherited from PropertyInstance
#current_value, #property, #resource, #value
Instance Method Summary collapse
-
#initialize(*_) ⇒ HashPropertyInstance
constructor
A new instance of HashPropertyInstance.
- #render ⇒ Object
- #set(key, new_value) ⇒ Object
Methods inherited from PropertyInstance
#current, #default, #transform, #validate!
Constructor Details
#initialize(*_) ⇒ HashPropertyInstance
Returns a new instance of HashPropertyInstance
205 206 207 208 209 210 |
# File 'lib/convection/model/template/resource.rb', line 205 def initialize(*_) super @value = {} @current_value = {} end |
Instance Method Details
#render ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/convection/model/template/resource.rb', line 216 def render value.keys.each_with_object({}) do |i, memo| memo[i] = if value[i].is_a?(Resource) value[i].reference elsif value[i].respond_to?(:render) value[i].render else value[i] end end end |
#set(key, new_value) ⇒ Object
212 213 214 |
# File 'lib/convection/model/template/resource.rb', line 212 def set(key, new_value) @value[key] = validate!(transform(new_value)) end |