Class: Ardb::RelationSpy
- Inherits:
-
Object
- Object
- Ardb::RelationSpy
- Defined in:
- lib/ardb/relation_spy.rb
Defined Under Namespace
Classes: AppliedExpression
Instance Attribute Summary collapse
-
#applied ⇒ Object
readonly
Returns the value of attribute applied.
-
#limit_value ⇒ Object
Returns the value of attribute limit_value.
-
#offset_value ⇒ Object
Returns the value of attribute offset_value.
-
#order_values ⇒ Object
Returns the value of attribute order_values.
-
#results ⇒ Object
Returns the value of attribute results.
-
#reverse_order_value ⇒ Object
Returns the value of attribute reverse_order_value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #all ⇒ Object
- #count ⇒ Object
-
#initialize ⇒ RelationSpy
constructor
A new instance of RelationSpy.
- #limit(value) ⇒ Object
- #offset(value) ⇒ Object
- #order(*args) ⇒ Object
Constructor Details
#initialize ⇒ RelationSpy
Returns a new instance of RelationSpy.
10 11 12 13 14 15 |
# File 'lib/ardb/relation_spy.rb', line 10 def initialize @applied, @results = [], [] @order_values = [] @reverse_order_value = nil @offset_value, @limit_value = nil, nil end |
Instance Attribute Details
#applied ⇒ Object (readonly)
Returns the value of attribute applied.
5 6 7 |
# File 'lib/ardb/relation_spy.rb', line 5 def applied @applied end |
#limit_value ⇒ Object
Returns the value of attribute limit_value.
7 8 9 |
# File 'lib/ardb/relation_spy.rb', line 7 def limit_value @limit_value end |
#offset_value ⇒ Object
Returns the value of attribute offset_value.
7 8 9 |
# File 'lib/ardb/relation_spy.rb', line 7 def offset_value @offset_value end |
#order_values ⇒ Object
Returns the value of attribute order_values.
6 7 8 |
# File 'lib/ardb/relation_spy.rb', line 6 def order_values @order_values end |
#results ⇒ Object
Returns the value of attribute results.
8 9 10 |
# File 'lib/ardb/relation_spy.rb', line 8 def results @results end |
#reverse_order_value ⇒ Object
Returns the value of attribute reverse_order_value.
6 7 8 |
# File 'lib/ardb/relation_spy.rb', line 6 def reverse_order_value @reverse_order_value end |
Instance Method Details
#==(other) ⇒ Object
57 58 59 |
# File 'lib/ardb/relation_spy.rb', line 57 def ==(other) @applied == other.applied end |
#all ⇒ Object
49 50 51 |
# File 'lib/ardb/relation_spy.rb', line 49 def all @results[(@offset_value || 0), (@limit_value || @results.size)] || [] end |
#count ⇒ Object
53 54 55 |
# File 'lib/ardb/relation_spy.rb', line 53 def count all.size end |
#limit(value) ⇒ Object
37 38 39 40 41 |
# File 'lib/ardb/relation_spy.rb', line 37 def limit(value) @limit_value = value ? value.to_i : nil @applied << AppliedExpression.new(:limit, [ value ]) self end |
#offset(value) ⇒ Object
43 44 45 46 47 |
# File 'lib/ardb/relation_spy.rb', line 43 def offset(value) @offset_value = value ? value.to_i : 0 @applied << AppliedExpression.new(:offset, [ value ]) self end |
#order(*args) ⇒ Object
31 32 33 34 35 |
# File 'lib/ardb/relation_spy.rb', line 31 def order(*args) @order_values += args @applied << AppliedExpression.new(:order, args) self end |