Class: QBFC::QBCollection
- Inherits:
-
Object
- Object
- QBFC::QBCollection
- Defined in:
- lib/qbfc/qb_collection.rb
Overview
A QBCollection object is used as an intermediate object when doing finds, for example, in qb_session.customers.find(:all), customers returns a QBCollection instance which then is sent the find call. The instance sends the find method on to the appropriate Class. The reason for having this intermediate class is to be able to pass a reference to the Session to the find method (or other class method).
There’s probably no reason to use this class directly.
Instance Method Summary collapse
-
#initialize(sess, class_name) ⇒ QBCollection
constructor
sessis a QBFC::Session object,class_nameis the name of a class descended from QBFC::Base. -
#method_missing(symbol, *params) ⇒ Object
Send any missing methods to the class, along with the
Sessionobject.
Constructor Details
#initialize(sess, class_name) ⇒ QBCollection
sess is a QBFC::Session object, class_name is the name of a class descended from QBFC::Base.
16 17 18 19 |
# File 'lib/qbfc/qb_collection.rb', line 16 def initialize(sess, class_name) @sess = sess @klass = QBFC::const_get(class_name) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *params) ⇒ Object
Send any missing methods to the class, along with the Session object
22 23 24 |
# File 'lib/qbfc/qb_collection.rb', line 22 def method_missing(symbol, *params) #:nodoc: @klass.send(symbol, @sess, *params) end |