Class: KashflowApi::SoapObject
- Inherits:
-
Object
- Object
- KashflowApi::SoapObject
- Defined in:
- lib/kashflow_api/soap_object.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ SoapObject
constructor
A new instance of SoapObject.
- #method_missing(method, set = nil) ⇒ Object
Constructor Details
#initialize(hash = nil) ⇒ SoapObject
Returns a new instance of SoapObject.
5 6 7 8 9 10 11 12 13 |
# File 'lib/kashflow_api/soap_object.rb', line 5 def initialize(hash = nil) if hash @hash = hash build_field_hash else @hash = blank_object_hash build_field_hash end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, set = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kashflow_api/soap_object.rb', line 15 def method_missing(method, set = nil) if @fields.keys.include? method @hash[@fields[method]] elsif method.to_s.scan(/.$/).join == "=" if @fields.keys.include? method.to_s.gsub(/\=/,'').to_sym @hash[@fields[method.to_s.gsub(/\=/,'').to_sym]] = set end else super end end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
3 4 5 |
# File 'lib/kashflow_api/soap_object.rb', line 3 def hash @hash end |
Class Method Details
.build_from_soap(hash) ⇒ Object
27 28 29 |
# File 'lib/kashflow_api/soap_object.rb', line 27 def self.build_from_soap(hash) self.new(hash) end |