Class: Parse::Query
- Inherits:
-
Object
- Object
- Parse::Query
- Defined in:
- lib/parse/query.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#order ⇒ Object
Returns the value of attribute order.
-
#order_by ⇒ Object
Returns the value of attribute order_by.
-
#skip ⇒ Object
Returns the value of attribute skip.
-
#where ⇒ Object
Returns the value of attribute where.
Instance Method Summary collapse
- #eq(field, value) ⇒ Object
- #exists(field, value = true) ⇒ Object
- #get ⇒ Object
- #greater_eq(field, value) ⇒ Object
- #greater_than(field, value) ⇒ Object
-
#initialize(cls_name) ⇒ Query
constructor
A new instance of Query.
- #less_eq(field, value) ⇒ Object
- #less_than(field, value) ⇒ Object
- #regex(field, expression) ⇒ Object
- #value_in(field, values) ⇒ Object
Constructor Details
#initialize(cls_name) ⇒ Query
Returns a new instance of Query.
13 14 15 16 17 |
# File 'lib/parse/query.rb', line 13 def initialize(cls_name) @class_name = cls_name @where = {} @order = :ascending end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
7 8 9 |
# File 'lib/parse/query.rb', line 7 def class_name @class_name end |
#limit ⇒ Object
Returns the value of attribute limit.
10 11 12 |
# File 'lib/parse/query.rb', line 10 def limit @limit end |
#order ⇒ Object
Returns the value of attribute order.
9 10 11 |
# File 'lib/parse/query.rb', line 9 def order @order end |
#order_by ⇒ Object
Returns the value of attribute order_by.
8 9 10 |
# File 'lib/parse/query.rb', line 8 def order_by @order_by end |
#skip ⇒ Object
Returns the value of attribute skip.
11 12 13 |
# File 'lib/parse/query.rb', line 11 def skip @skip end |
#where ⇒ Object
Returns the value of attribute where.
6 7 8 |
# File 'lib/parse/query.rb', line 6 def where @where end |
Instance Method Details
#eq(field, value) ⇒ Object
29 30 31 32 |
# File 'lib/parse/query.rb', line 29 def eq(field, value) add_constraint field, value self end |
#exists(field, value = true) ⇒ Object
64 65 66 67 |
# File 'lib/parse/query.rb', line 64 def exists(field, value = true) add_constraint field, { "$exists" => value } self end |
#get ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/parse/query.rb', line 69 def get uri = Protocol.class_uri @class_name query = { "where" => CGI.escape(@where.to_json) } response = Parse.client.request uri, :get, nil, query Parse.parse_json class_name, response end |
#greater_eq(field, value) ⇒ Object
54 55 56 57 |
# File 'lib/parse/query.rb', line 54 def greater_eq(field, value) add_constraint field, { "$gte" => value } self end |
#greater_than(field, value) ⇒ Object
49 50 51 52 |
# File 'lib/parse/query.rb', line 49 def greater_than(field, value) add_constraint field, { "$gt" => value } self end |
#less_eq(field, value) ⇒ Object
44 45 46 47 |
# File 'lib/parse/query.rb', line 44 def less_eq(field, value) add_constraint field, { "$lte" => value } self end |
#less_than(field, value) ⇒ Object
39 40 41 42 |
# File 'lib/parse/query.rb', line 39 def less_than(field, value) add_constraint field, { "$lt" => value } self end |
#regex(field, expression) ⇒ Object
34 35 36 37 |
# File 'lib/parse/query.rb', line 34 def regex(field, expression) add_constraint field, { "$regex" => expression } self end |
#value_in(field, values) ⇒ Object
59 60 61 62 |
# File 'lib/parse/query.rb', line 59 def value_in(field, values) add_constraint field, { "$in" => values } self end |