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
Class Attribute Summary collapse
-
.entity_name ⇒ Object
Returns the value of attribute entity_name.
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.
32 33 34 35 |
# File 'lib/service/record.rb', line 32 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
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/service/record.rb', line 67 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 |
Class Attribute Details
.entity_name ⇒ Object
Returns the value of attribute entity_name.
8 9 10 |
# File 'lib/service/record.rb', line 8 def entity_name @entity_name end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
15 16 17 |
# File 'lib/service/record.rb', line 15 def attributes @attributes end |
#is_new_record ⇒ Object
Returns the value of attribute is_new_record.
17 18 19 |
# File 'lib/service/record.rb', line 17 def is_new_record @is_new_record end |
Class Method Details
.quickbook_gateway ⇒ Object
24 25 26 |
# File 'lib/service/record.rb', line 24 def self.quickbook_gateway return @@quickbook_gateway end |
.quickbook_gateway=(gateway) ⇒ Object
Set instance of Gateway::QuickBook
20 21 22 |
# File 'lib/service/record.rb', line 20 def self.quickbook_gateway=(gateway) @@quickbook_gateway = gateway end |
Instance Method Details
#[](key) ⇒ Object
59 60 61 |
# File 'lib/service/record.rb', line 59 def [](key) return self.attributes[key.to_s] end |
#[]=(key, value) ⇒ Object
63 64 65 |
# File 'lib/service/record.rb', line 63 def []=(key, value) self.attributes[key.to_s] = value end |
#quickbook_gateway ⇒ Object
28 29 30 |
# File 'lib/service/record.rb', line 28 def quickbook_gateway return @@quickbook_gateway end |