Class: Queryko::QueryObject
- Inherits:
-
Object
- Object
- Queryko::QueryObject
- Includes:
- Naming, RangeAttributes, Searchables
- Defined in:
- lib/queryko/query_object.rb
Instance Attribute Summary collapse
-
#countable_resource ⇒ Object
readonly
Returns the value of attribute countable_resource.
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
include AfterAttributes.
Instance Method Summary collapse
- #call ⇒ Object
- #count ⇒ Object
-
#initialize(params = {}, rel) ⇒ QueryObject
constructor
A new instance of QueryObject.
- #perform ⇒ Object
- #total_count ⇒ Object
Methods included from Searchables
Methods included from RangeAttributes
Methods included from Naming
Constructor Details
#initialize(params = {}, rel) ⇒ QueryObject
Returns a new instance of QueryObject.
20 21 22 23 |
# File 'lib/queryko/query_object.rb', line 20 def initialize(params = {}, rel) @relation = @original_relation = rel @params = params end |
Instance Attribute Details
#countable_resource ⇒ Object (readonly)
Returns the value of attribute countable_resource.
9 10 11 |
# File 'lib/queryko/query_object.rb', line 9 def countable_resource @countable_resource end |
Class Method Details
.inherited(subclass) ⇒ Object
include AfterAttributes
15 16 17 18 |
# File 'lib/queryko/query_object.rb', line 15 def self.inherited(subclass) # It should not be executed when using anonymous class subclass.table_name inferred_from_class_name(subclass) if subclass.name end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 |
# File 'lib/queryko/query_object.rb', line 25 def call perform self.relation = paginate if config[:paginate] return relation end |
#count ⇒ Object
48 49 50 |
# File 'lib/queryko/query_object.rb', line 48 def count call.to_a.count end |
#perform ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/queryko/query_object.rb', line 31 def perform return if @performed @performed = true pre_filter filter filter_by_range_attributes filter_by_searchables @countable_resource = relation end |
#total_count ⇒ Object
43 44 45 46 |
# File 'lib/queryko/query_object.rb', line 43 def total_count perform countable_resource.count end |