Sha256: 099c07cbd862480e4a2766a164eac5b59613649e9ad5b217a11bd7b445885c1c
Contents?: true
Size: 751 Bytes
Versions: 23
Compression:
Stored size: 751 Bytes
Contents
module ModelWrapper # For cretain values, we wrap them to make the behave as a # model. def wrap_value(value, lookup) if value.cur.is_a?(Array) value = new_array_model(value, @options.merge(parent: self, path: path + lookup)) elsif value.cur.is_a?(Hash) value = new_model(value, @options.merge(parent: self, path: path + lookup)) end return value end def wrap_values(values, lookup=[]) if values.cur.is_a?(Array) # Coming from an array values = values.map {|v| wrap_value(v,lookup + [:[]]) } elsif values.cur.is_a?(Hash) pairs = values.map do |k,v| path = lookup + [k] [k, wrap_value(v,path)] end values = Hash[pairs] end return values end end
Version data entries
23 entries across 23 versions & 1 rubygems