Sha256: 78d2a559960f3c9d7588845dc8262b82ecfe7985d6f0437b9c581c2399cb169b
Contents?: true
Size: 778 Bytes
Versions: 31
Compression:
Stored size: 778 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
31 entries across 31 versions & 1 rubygems