Module: Spreedly::Fields

Included in:
AuthMode, Credential, DeliverPaymentResponse, GatewayClass, Model, Response, ShippingAddress
Defined in:
lib/spreedly/common/fields.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/spreedly/common/fields.rb', line 4

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#field_hashObject



15
16
17
18
19
20
# File 'lib/spreedly/common/fields.rb', line 15

def field_hash
  self.class.fields.inject({}) do |hash, each|
    hash[each] = send(each)
    hash
  end
end

#initialize_fields(xml_doc) ⇒ Object



8
9
10
11
12
13
# File 'lib/spreedly/common/fields.rb', line 8

def initialize_fields(xml_doc)
  self.class.fields.each do |field|
    value = xml_doc.at_xpath(".//#{field}").inner_html.strip
    instance_variable_set("@#{field}", value)
  end
end