Module: Lockstep::QueryMethods::ClassMethods

Defined in:
app/concepts/lockstep/query_methods.rb

Instance Method Summary collapse

Instance Method Details

#allArray

Find all Lockstep::ApiRecord objects for that model.

Returns:

  • (Array)

    an ‘Array` of objects that subclass `Lockstep::ApiRecord`.



40
41
42
# File 'app/concepts/lockstep/query_methods.rb', line 40

def all
  query_builder.all
end

#countObject

Add this at the end of a method chain to get the count of objects, instead of an Array of objects



32
33
34
35
# File 'app/concepts/lockstep/query_methods.rb', line 32

def count
  #https://www.parse.com/docs/rest#queries-counting
  query_builder.count
end

#firstObject

Find the first object. Fairly random, not based on any specific condition.



46
47
48
# File 'app/concepts/lockstep/query_methods.rb', line 46

def first
  query_builder.limit(1).first
end

#include_object(*associations) ⇒ Object

Include the attributes of a parent ojbect in the results Similar to ActiveRecord eager loading



27
28
29
# File 'app/concepts/lockstep/query_methods.rb', line 27

def include_object(*associations)
  query_builder.include_object(*associations)
end

#limit(n) ⇒ Object

Limits the number of objects returned



52
53
54
# File 'app/concepts/lockstep/query_methods.rb', line 52

def limit(n)
  query_builder.limit(n)
end

#noneObject



20
21
22
# File 'app/concepts/lockstep/query_methods.rb', line 20

def none
  query_builder.none
end

#order(*attr) ⇒ Object



62
63
64
# File 'app/concepts/lockstep/query_methods.rb', line 62

def order(*attr)
  query_builder.order(*attr)
end

#page(n) ⇒ Object

Skip the number of objects



58
59
60
# File 'app/concepts/lockstep/query_methods.rb', line 58

def page(n)
  query_builder.page(n)
end

#query_builderObject



7
8
9
10
11
12
13
14
# File 'app/concepts/lockstep/query_methods.rb', line 7

def query_builder
  @query_builder = Query.new(self)
  unless scopes[:default_scope].nil?
    @query_builder.criteria.deep_merge!(Lockstep::ApiRecord.instance_exec(&scopes[:default_scope]).criteria)
  end

  @query_builder
end

#reorder(*attr) ⇒ Object



66
67
68
# File 'app/concepts/lockstep/query_methods.rb', line 66

def reorder(*attr)
  query_builder.reorder(*attr)
end

#unscopedObject



16
17
18
# File 'app/concepts/lockstep/query_methods.rb', line 16

def unscoped
  Query.new(self)
end