Class: QBFC::Base
- Inherits:
-
Object
- Object
- QBFC::Base
- Defined in:
- lib/qbfc/base.rb
Overview
Base is the…um…“base” class from which Element, Info, and Report inherit. It defines methods that the three share.
Class Method Summary collapse
-
.create_query(sess) ⇒ Object
A convenience method for creating and returning a Query Request for this class.
-
.is_base_class? ⇒ Boolean
is_base_class? is used by Element and subclasses.
-
.parse_find_args(*args) ⇒ Object
Element::find and Info::get receive optional arguments which can include a Request object and/or an options Hash.
-
.qb_name ⇒ Object
The QuickBooks name for this Element or Report.
Instance Method Summary collapse
-
#initialize(sess, ole = nil) ⇒ Base
constructor
Create an instance of this Element or Report.
-
#method_missing(symbol, *params) ⇒ Object
Pass missing methods to OLEWrapper#qbfc_method_missing to handle checking if there is a related OLE method to run.
-
#ole_methods ⇒ Object
List the methods of the OLE object.
-
#qb_name ⇒ Object
Name of the QuickBooks Element or Query represented by this class.
-
#respond_to_ole?(symbol) ⇒ Boolean
Check if the OLE object responds to a given method.
Constructor Details
#initialize(sess, ole = nil) ⇒ Base
Create an instance of this Element or Report.
-
sess
: An open QBFC::Session object that will recieve all requests -
ole
: An optional QBFC::OLEWrapper object representing a response to a QueryRq. It is unlikely that this will be used directly.
55 56 57 58 |
# File 'lib/qbfc/base.rb', line 55 def initialize(sess, ole = nil) @sess, @ole = sess, ole @ole = QBFC::OLEWrapper.new(@ole) if @ole.kind_of?(WIN32OLE) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *params) ⇒ Object
Pass missing methods to OLEWrapper#qbfc_method_missing to handle checking if there is a related OLE method to run.
72 73 74 |
# File 'lib/qbfc/base.rb', line 72 def method_missing(symbol, *params) @ole.qbfc_method_missing(@sess, symbol, *params) end |
Class Method Details
.create_query(sess) ⇒ Object
A convenience method for creating and returning a Query Request for this class.
36 37 38 |
# File 'lib/qbfc/base.rb', line 36 def create_query(sess) QBFC::Request.new(sess, "#{qb_name}Query") end |
.is_base_class? ⇒ Boolean
is_base_class? is used by Element and subclasses. It is included in Base because some Base methods may check for it.
9 10 11 |
# File 'lib/qbfc/base.rb', line 9 def is_base_class? #:nodoc: false end |
.parse_find_args(*args) ⇒ Object
Element::find and Info::get receive optional arguments which can include a Request object and/or an options Hash. parse_find_args
gets these arguments into a set that is easier to deal with.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/qbfc/base.rb', line 16 def parse_find_args(*args) request = args[0].kind_of?(QBFC::Request) ? args[0].dup : nil = args[-1].kind_of?(Hash) ? args[-1].dup : {} # base classes will need to pass a subset of options to # the ChildClass.find . Also, the actually options to the # BaseClass.find Request cannot include owner_id. if is_base_class? = .dup .delete(:conditions) .delete(:owner_id) else = nil end return request, , end |
.qb_name ⇒ Object
The QuickBooks name for this Element or Report. It typically matches the last part of class name. Used in determining names of Requests and other OLE methods.
46 47 48 |
# File 'lib/qbfc/base.rb', line 46 def qb_name self.name.split('::').last end |
Instance Method Details
#ole_methods ⇒ Object
List the methods of the OLE object
61 62 63 |
# File 'lib/qbfc/base.rb', line 61 def ole_methods @ole.ole_methods end |
#qb_name ⇒ Object
Name of the QuickBooks Element or Query represented by this class.
77 78 79 |
# File 'lib/qbfc/base.rb', line 77 def qb_name self.class.qb_name end |
#respond_to_ole?(symbol) ⇒ Boolean
Check if the OLE object responds to a given method
66 67 68 |
# File 'lib/qbfc/base.rb', line 66 def respond_to_ole?(symbol) @ole.respond_to_ole?(symbol) end |