Sha256: 9d9dcaec6d9eac1daf76b211e0c03c362b0843738f8ad4b1b352911e79aabc5b
Contents?: true
Size: 718 Bytes
Versions: 11
Compression:
Stored size: 718 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, self, path + lookup) elsif value.cur.is_a?(Hash) value = new_model(value, self, 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
11 entries across 11 versions & 1 rubygems