class AxiomusApi::Base
Public Class Methods
attribute_meta()
click to toggle source
# File lib/axiomus_api/base.rb, line 36 def self.attribute_meta res = superclass.respond_to?(:attribute_meta) ? superclass.attribute_meta : {} res.merge(@attr_info || {}) end
extract_options(args)
click to toggle source
# File lib/axiomus_api/base.rb, line 57 def self.extract_options(args) if args.last.is_a?(Hash) && args.last.instance_of?(Hash) args.pop else {} end end
new()
click to toggle source
# File lib/axiomus_api/base.rb, line 65 def initialize self.class.attribute_meta.each do |k, v| if v[:array] self.send("#{k}=".to_sym, []) elsif v[:type] self.send("#{k}=".to_sym, v[:type].new) end end end
tag_name()
click to toggle source
# File lib/axiomus_api/base.rb, line 41 def self.tag_name if @xml_element.nil? if superclass.respond_to?(:tag_name) superclass.tag_name else raise 'xml_element not specified' end else @xml_element end end
xml_attribute(*args)
click to toggle source
# File lib/axiomus_api/base.rb, line 26 def self.xml_attribute(*args) options = extract_options(args) args << options.merge({xml_type: :attribute}) xml_field(*args) end
xml_element(element_name)
click to toggle source
# File lib/axiomus_api/base.rb, line 8 def self.xml_element(element_name) @xml_element = element_name end
xml_field(*args)
click to toggle source
# File lib/axiomus_api/base.rb, line 12 def self.xml_field(*args) options = extract_options(args) options.keys.each do |k| raise "Wrong attribute #{k}" if ![:xml_type, :xml_name, :optional, :type, :array, :max_occurs].include?(k) end args.each do |attr_name| @attr_info ||= {} @attr_info[attr_name] = options attr_accessor attr_name end end
xml_field_array(name, options = {})
click to toggle source
# File lib/axiomus_api/base.rb, line 32 def self.xml_field_array(name, options = {}) xml_field(name, options.merge({array: true})) end
Public Instance Methods
tag_name()
click to toggle source
# File lib/axiomus_api/base.rb, line 53 def tag_name self.class.tag_name end