Class: Queryko::QueryObject
- Inherits:
-
Object
- Object
- Queryko::QueryObject
- Includes:
- RangeAttributes, Searchables
- Defined in:
- lib/queryko/query_object.rb
Instance Attribute Summary collapse
-
#countable_resource ⇒ Object
readonly
Returns the value of attribute countable_resource.
Instance Method Summary collapse
- #call ⇒ Object
- #count ⇒ Object
-
#initialize(params = {}, rel) ⇒ QueryObject
constructor
include AfterAttributes.
- #perform ⇒ Object
- #total_count ⇒ Object
Methods included from Searchables
Methods included from RangeAttributes
Constructor Details
#initialize(params = {}, rel) ⇒ QueryObject
include AfterAttributes
12 13 14 15 |
# File 'lib/queryko/query_object.rb', line 12 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.
7 8 9 |
# File 'lib/queryko/query_object.rb', line 7 def countable_resource @countable_resource end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 |
# File 'lib/queryko/query_object.rb', line 17 def call perform self.relation = paginate if config[:paginate] return relation end |
#count ⇒ Object
40 41 42 |
# File 'lib/queryko/query_object.rb', line 40 def count call.to_a.count end |
#perform ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/queryko/query_object.rb', line 23 def perform return if @performed @performed = true pre_filter filter filter_by_range_attributes filter_by_searchables @countable_resource = relation end |
#total_count ⇒ Object
35 36 37 38 |
# File 'lib/queryko/query_object.rb', line 35 def total_count perform countable_resource.count end |