Class: RubyOmx::Node

Inherits:
Object
  • Object
show all
Includes:
ROXML
Defined in:
lib/ruby_omx/node.rb

Overview

Base class for request and response classes, which implement XML mapping via ROXML

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Node

Returns a new instance of Node.



8
9
10
# File 'lib/ruby_omx/node.rb', line 8

def initialize(attrs={})
  attrs.map { |(k, v)| send("#{k}=", v) } if attrs.present?
end

Instance Method Details

#accessorsObject



12
13
14
# File 'lib/ruby_omx/node.rb', line 12

def accessors
  roxml_references.map {|r| r.accessor}
end

#as_hashObject

render a ROXML node as a normal hash, eliminating the @ and some unneeded admin fields



17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_omx/node.rb', line 17

def as_hash
	obj_hash = {}
	self.instance_variables.each do |v|
		m = v.to_s.sub('@','')
		if m != 'roxml_references' && m!= 'promotion_ids'
			obj_hash[m.to_sym] = self.instance_variable_get(v)
		end
	end
	return obj_hash
end