Sha256: 1392c67f3da117ad9e8a3ac3a7f065adb8e2a8c885402a5fd752eb8826afb202
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 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) return unless hash 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) return false unless hash param_value(params) do |hash_params| if 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
5 entries across 5 versions & 1 rubygems