class Ecircle::Base
Attributes
all_fields[R]
id[R]
named_attrs[R]
Public Class Methods
new()
click to toggle source
# File lib/ecircle/base.rb, line 13 def initialize @id, @all_fields, @named_attrs = "", {}, {} end
Public Instance Methods
[](name)
click to toggle source
# File lib/ecircle/base.rb, line 9 def [](name) @all_fields[name.to_sym] end
id=(value)
click to toggle source
# File lib/ecircle/base.rb, line 5 def id=(value) @id = value end
init_with_xml(element_name, xml_string)
click to toggle source
# File lib/ecircle/base.rb, line 17 def init_with_xml(element_name, xml_string) n = Nokogiri.parse(xml_string) @id = n.xpath("#{element_name}/@id" ).to_s @all_fields = Hash[ n.xpath("//#{element_name}/*").collect do |a| [a.name.to_sym, a.children.first.to_s] end ] @named_attrs = Hash[ n.xpath("#{element_name}/namedattr").collect do |a| [a.attributes["name"].value, a.children.empty? ? "" : a.children.first.to_s] end ] end
method_missing(method, *args, &block)
click to toggle source
Handle all assignments, everything else is propagated to super.
Calls superclass method
# File lib/ecircle/base.rb, line 30 def method_missing(method, *args, &block) case method.to_s when /\[\]=/ then super when /(.+)=/ @all_fields[$1.to_sym] = args.first else super end end