Class: Lotus::Model::Adapters::Auth0::Query
- Inherits:
-
Object
- Object
- Lotus::Model::Adapters::Auth0::Query
- Defined in:
- lib/lotus/model/adapters/auth0/query.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(collection, mapped_collection, context = nil, &block) ⇒ Query
constructor
A new instance of Query.
- #limit(limit) ⇒ Object
- #offset(num) ⇒ Object
- #or(condition = nil, &block) ⇒ Object
- #sort(*args) ⇒ Object
- #where(condition = nil, &block) ⇒ Object (also: #and)
Constructor Details
#initialize(collection, mapped_collection, context = nil, &block) ⇒ Query
Returns a new instance of Query.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 11 def initialize(collection, mapped_collection, context = nil, &block) @collection, @mapped_collection, @context = collection, mapped_collection, context @conditions = [] @limit = nil @sort_order = nil @sort_key = nil @offset = nil instance_eval(&block) if block_given? end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
9 10 11 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 9 def conditions @conditions end |
Instance Method Details
#all ⇒ Object
23 24 25 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 23 def all _deserialize(run) end |
#limit(limit) ⇒ Object
27 28 29 30 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 27 def limit(limit) @limit = limit all end |
#offset(num) ⇒ Object
40 41 42 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 40 def offset(num) @offset = num end |
#or(condition = nil, &block) ⇒ Object
50 51 52 53 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 50 def or(condition = nil, &block) _push_to_conditions(:or, condition || blk) self end |
#sort(*args) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 32 def sort(*args) if args[-1].is_a?(Array) @sort_order = args.pop end raise ArgumentError, 'you can only sort on one key' unless args.count == 1 @sort_key = args.first end |
#where(condition = nil, &block) ⇒ Object Also known as: and
44 45 46 47 |
# File 'lib/lotus/model/adapters/auth0/query.rb', line 44 def where(condition = nil, &block) _push_to_conditions(:where, condition || blk) self end |