Class: Service::Record
- Inherits:
-
Object
- Object
- Service::Record
- Extended by:
- Finder
- Includes:
- Errors, Persistence
- Defined in:
- lib/service/record.rb
Overview
Base class use to map QuickBook record with Ruby instance QuickBook API documentation developer.intuit.com/v2/apiexplorer?apiname=V3QBO
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#is_new_record ⇒ Object
Returns the value of attribute is_new_record.
Class Method Summary collapse
- .quickbook_gateway ⇒ Object
-
.quickbook_gateway=(gateway) ⇒ Object
Set instance of Gateway::QuickBook.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(attributes = {}) ⇒ Record
constructor
A new instance of Record.
- #method_missing(method_sym, *args, &block) ⇒ Object
- #quickbook_gateway ⇒ Object
Methods included from Finder
extended, find, find_all, find_or_initialize
Methods included from Persistence
Constructor Details
#initialize(attributes = {}) ⇒ Record
Returns a new instance of Record.
26 27 28 29 |
# File 'lib/service/record.rb', line 26 def initialize(attributes = {}) self.is_new_record = true self.attributes = attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *args, &block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/service/record.rb', line 49 def method_missing(method_sym, *args, &block) attribute = method_sym.to_s if (args.length == 1 and method_sym.to_s[-1, 1] == "=") self[attribute[(0..method_sym.length - 2)].to_s] = args[0] elsif (self.attributes.keys.index(attribute)) return self[attribute] else super end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
11 12 13 |
# File 'lib/service/record.rb', line 11 def attributes @attributes end |
#is_new_record ⇒ Object
Returns the value of attribute is_new_record.
11 12 13 |
# File 'lib/service/record.rb', line 11 def is_new_record @is_new_record end |
Class Method Details
.quickbook_gateway ⇒ Object
18 19 20 |
# File 'lib/service/record.rb', line 18 def self.quickbook_gateway return @@quickbook_gateway end |
.quickbook_gateway=(gateway) ⇒ Object
Set instance of Gateway::QuickBook
14 15 16 |
# File 'lib/service/record.rb', line 14 def self.quickbook_gateway=(gateway) @@quickbook_gateway = gateway end |
Instance Method Details
#[](key) ⇒ Object
41 42 43 |
# File 'lib/service/record.rb', line 41 def [](key) return self.attributes[key.to_s] end |
#[]=(key, value) ⇒ Object
45 46 47 |
# File 'lib/service/record.rb', line 45 def []=(key, value) self.attributes[key.to_s] = value end |
#quickbook_gateway ⇒ Object
22 23 24 |
# File 'lib/service/record.rb', line 22 def quickbook_gateway return @@quickbook_gateway end |