Module: ModelWrapper
- Included in:
- ArrayModel, Model
- Defined in:
- lib/volt/models/model_wrapper.rb
Instance Method Summary collapse
-
#wrap_value(value) ⇒ Object
For cretain values, we wrap them to make the behave as a model.
- #wrap_values(values) ⇒ Object
Instance Method Details
#wrap_value(value) ⇒ Object
For cretain values, we wrap them to make the behave as a model.
4 5 6 7 8 9 10 11 12 |
# File 'lib/volt/models/model_wrapper.rb', line 4 def wrap_value(value) if value.cur.is_a?(Array) value = ArrayModel.new(value, self, nil) elsif value.cur.is_a?(Hash) value = Model.new(value) end return value end |
#wrap_values(values) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/volt/models/model_wrapper.rb', line 14 def wrap_values(values) if values.cur.is_a?(Array) values = values.map {|v| wrap_value(v) } elsif values.cur.is_a?(Hash) values = Hash[values.map {|k,v| [k, wrap_value(v)] }] end return values end |