module Agris::XmlModel::InstanceMethods
Attributes
hash[R]
Public Class Methods
new(hash = {})
click to toggle source
# File lib/agris/xml_model.rb, line 19 def initialize(hash = {}) @hash = hash @hash.each do |key, value| instance_variable_set("@#{key}", value) end end
Public Instance Methods
attributes()
click to toggle source
# File lib/agris/xml_model.rb, line 12 def attributes (instance_variables - [:@hash]).each_with_object({}) do |ivar, new_hash| new_hash[ivar.to_s.delete('@')] = instance_variable_get(ivar) new_hash end end
to_xml_hash()
click to toggle source
# File lib/agris/xml_model.rb, line 26 def to_xml_hash ignore_attributes = (xml_ignore_attributes + [:hash]).map(&:to_s) match_attributes = attributes.keys - ignore_attributes attributes .select { |key, _value| match_attributes.include?(key) } .each_with_object({}) do |(name, value), new_hash| new_hash["@#{name.delete('_')}".to_sym] = value new_hash end end
xml_ignore_attributes()
click to toggle source
# File lib/agris/xml_model.rb, line 37 def xml_ignore_attributes [] end