Module: Rql::Dsl::Comparisons
- Included in:
- Context
- Defined in:
- lib/rql/dsl/comparisons.rb
Instance Method Summary collapse
- #<(value) ⇒ Object
- #<=(value) ⇒ Object
- #==(value) ⇒ Object
- #===(range) ⇒ Object
- #>(value) ⇒ Object
- #>=(value) ⇒ Object
- #end_with?(value) ⇒ Boolean
- #in?(collection) ⇒ Boolean
- #include?(value) ⇒ Boolean
- #start_with?(value) ⇒ Boolean
Instance Method Details
#<(value) ⇒ Object
14 15 16 |
# File 'lib/rql/dsl/comparisons.rb', line 14 def <(value) Context.new(@model, arel.lt(value)) end |
#<=(value) ⇒ Object
22 23 24 |
# File 'lib/rql/dsl/comparisons.rb', line 22 def <=(value) Context.new(@model, arel.lteq(value)) end |
#==(value) ⇒ Object
4 5 6 |
# File 'lib/rql/dsl/comparisons.rb', line 4 def ==(value) Context.new(@model, arel.eq(value)) end |
#===(range) ⇒ Object
8 9 10 11 12 |
# File 'lib/rql/dsl/comparisons.rb', line 8 def ===(range) min_query = (range.min != -Float::INFINITY) ? arel.gt(range.min) : Arel.sql('1').eq(1) max_query = (range.max != Float::INFINITY) ? arel.lt(range.max) : Arel.sql('1').eq(1) Context.new(@model, min_query.and(max_query)) end |
#>(value) ⇒ Object
18 19 20 |
# File 'lib/rql/dsl/comparisons.rb', line 18 def >(value) Context.new(@model, arel.gt(value)) end |
#>=(value) ⇒ Object
26 27 28 |
# File 'lib/rql/dsl/comparisons.rb', line 26 def >=(value) Context.new(@model, arel.gteq(value)) end |
#end_with?(value) ⇒ Boolean
34 35 36 |
# File 'lib/rql/dsl/comparisons.rb', line 34 def end_with?(value) Context.new(@model, arel.matches("%#{value}")) end |
#in?(collection) ⇒ Boolean
42 43 44 45 |
# File 'lib/rql/dsl/comparisons.rb', line 42 def in?(collection) collection = collection.is_a?(Array) ? collection : collection.arel Context.new(@model, arel.in(collection)) end |