Module: Queryable::DefaultQuery::ClassMethods
- Defined in:
- lib/queryable/default_query.rb
Instance Method Summary collapse
-
#default_query ⇒ Object
Internal: Default query for the object, can be overriden by subclasses.
-
#queryable(collection) ⇒ Object
Public: Sets the default table or collection for this query object.
-
#queryable_class ⇒ Object
Internal: Attempts to use the parent query collection (if any), and provides a default based on a convention of the query object name.
Instance Method Details
#default_query ⇒ Object
Internal: Default query for the object, can be overriden by subclasses.
Returns a criteriable or chainable query of some sort.
27 28 29 |
# File 'lib/queryable/default_query.rb', line 27 def default_query queryable_class.all end |
#queryable(collection) ⇒ Object
Public: Sets the default table or collection for this query object.
collection - A model or static query.
20 21 22 |
# File 'lib/queryable/default_query.rb', line 20 def queryable(collection) @queryable_class = collection end |
#queryable_class ⇒ Object
Internal: Attempts to use the parent query collection (if any), and provides a default based on a convention of the query object name.
33 34 35 36 37 38 39 |
# File 'lib/queryable/default_query.rb', line 33 def queryable_class unless defined?(@queryable_class) @queryable_class = superclass.respond_to?(:queryable_class) && superclass.queryable_class || Object.const_get(name.gsub('sQuery', '')) end @queryable_class end |