Class: QbwcRequests::Base

Inherits:
Object
  • Object
show all
Includes:
OrderedFields, XmlActions
Defined in:
lib/qbwc_requests/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from XmlActions

header, header_attributes, query

Methods included from OrderedFields

included, #ordered_fields

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
# File 'lib/qbwc_requests/base.rb', line 11

def initialize(attributes = {})
  @attributes = compact(attributes)
  @attributes.each do |name, value|
    self.instance_variable_set("@#{name}", value) if value.present?
  end
end

Class Method Details

.qbxml(hash) ⇒ Object



18
19
20
# File 'lib/qbwc_requests/base.rb', line 18

def self.qbxml hash
  Qbxml.new(:qb, "#{version.to_i}.0").to_qbxml(hash)
end

.versionObject



26
27
28
# File 'lib/qbwc_requests/base.rb', line 26

def self.version
  self.name.split("::")[2].gsub("V","")
end

Instance Method Details

#class_nameObject



22
23
24
# File 'lib/qbwc_requests/base.rb', line 22

def class_name
  self.class.underscore(self.class.name.split("::")[1].gsub("Qbxml",""))
end

#persisted?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/qbwc_requests/base.rb', line 30

def persisted?
  false
end

#to_xml(request_id) ⇒ Object



7
8
9
# File 'lib/qbwc_requests/base.rb', line 7

def to_xml request_id
  self.valid? ? xml(request_id, self.class.name.demodulize) : self
end