Sha256: 0c7e5221c90ad1b4c0d8aa80199c1ab981fdb43b9d9d6cbacd9a609734d6ae51
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
module Rumx class HashAttribute < Attribute def initialize(name, type, description, allow_read, allow_write, options) super raise 'Hash attribute called without hash_type option' unless options[:hash_type] @hash_type = Type.find(options[:hash_type]) end def each_attribute_info(bean, ancestry, &block) hash = bean.send(name) child_ancestry = ancestry+[name] index_index = child_ancestry.size hash.each do |name, value| value = nil unless allow_read child_ancestry[index_index] = name yield AttributeInfo.new(self, bean, child_ancestry, value) end end def write?(bean, params) #puts "hash write params=#{params.inspect}" return false unless params.kind_of?(Hash) is_written = false if allow_write hash = bean.send(name) param_value(params) do |hash_params| if hash && hash_params && hash_params.kind_of?(Hash) hash_params.each do |name, value| hash[name.to_sym] = @hash_type.string_to_value(value) is_written = true end end end end return is_written end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rumx-0.1.2 | lib/rumx/hash_attribute.rb |
rumx-0.1.1 | lib/rumx/hash_attribute.rb |
rumx-0.1.0 | lib/rumx/hash_attribute.rb |