module FamilySearch::Gedcomx::SuperCoercion::InstanceMethods
Public Instance Methods
[]=(key, value)
click to toggle source
Calls superclass method
# File lib/familysearch/gedcomx/super_coercion.rb, line 40 def []=(key, value) if value && [Array,Hash].include?(value.class) into = self.class.key_coercion(key) || self.class.value_coercion(value) if value && into if into.class == Array && value.class == Array value = value.collect do |v| if into[0].respond_to?(:coerce) into[0].coerce(v) else into[0].new(v) end end elsif into.class == Hash && value.class == Hash into_value = into['key'] value = value.inject({}) do |h, (k, v)| if into_value.respond_to?(:coerce) h[k] = into_value.coerce(v) else h[k] = into_value.new(v) end h end else if into.respond_to?(:coerce) value = into.coerce(value) else value = into.new(value) end end end end super(key, value) end
custom_writer(key, value)
click to toggle source
# File lib/familysearch/gedcomx/super_coercion.rb, line 75 def custom_writer(key, value) self[key] = value end
replace(other_hash)
click to toggle source
# File lib/familysearch/gedcomx/super_coercion.rb, line 79 def replace(other_hash) (keys - other_hash.keys).each { |key| delete(key) } other_hash.each { |key, value| self[key] = value } self end