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.
Instance Method Summary collapse
- #call ⇒ Object
- #count ⇒ Object
-
#initialize(params = {}, rel) ⇒ QueryObject
constructor
include AfterAttributes.
- #perform ⇒ Object
- #total_count ⇒ Object
Methods included from Naming
Methods included from Searchables
Methods included from RangeAttributes
Constructor Details
#initialize(params = {}, rel) ⇒ QueryObject
include AfterAttributes
15 16 17 18 |
# File 'lib/queryko/query_object.rb', line 15 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 |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 |
# File 'lib/queryko/query_object.rb', line 20 def call perform self.relation = paginate if config[:paginate] return relation end |
#count ⇒ Object
43 44 45 |
# File 'lib/queryko/query_object.rb', line 43 def count call.to_a.count end |
#perform ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/queryko/query_object.rb', line 26 def perform return if @performed @performed = true pre_filter filter filter_by_range_attributes filter_by_searchables @countable_resource = relation end |
#total_count ⇒ Object
38 39 40 41 |
# File 'lib/queryko/query_object.rb', line 38 def total_count perform countable_resource.count end |