Module: Rql::Dsl::Comparisons
- Included in:
- Context
- Defined in:
- lib/rql/dsl/comparisons.rb
Instance Method Summary collapse
- #!=(value) ⇒ Object
- #<(value) ⇒ Object
- #<=(value) ⇒ Object
- #==(value) ⇒ Object
- #===(range) ⇒ Object
- #=~(value) ⇒ Object
- #>(value) ⇒ Object
- #>=(value) ⇒ Object
- #end_with?(value) ⇒ Boolean
- #in?(collection) ⇒ Boolean
- #include?(value) ⇒ Boolean
- #start_with?(value) ⇒ Boolean
Instance Method Details
#!=(value) ⇒ Object
8 9 10 |
# File 'lib/rql/dsl/comparisons.rb', line 8 def !=(value) Context.new(@model, arel.not_eq(value)) end |
#<(value) ⇒ Object
18 19 20 |
# File 'lib/rql/dsl/comparisons.rb', line 18 def <(value) Context.new(@model, arel.lt(value)) end |
#<=(value) ⇒ Object
26 27 28 |
# File 'lib/rql/dsl/comparisons.rb', line 26 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
12 13 14 15 16 |
# File 'lib/rql/dsl/comparisons.rb', line 12 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
34 35 36 |
# File 'lib/rql/dsl/comparisons.rb', line 34 def =~(value) Context.new(@model, arel.matches_regexp(value.source, !value.casefold?)) end |
#>(value) ⇒ Object
22 23 24 |
# File 'lib/rql/dsl/comparisons.rb', line 22 def >(value) Context.new(@model, arel.gt(value)) end |
#>=(value) ⇒ Object
30 31 32 |
# File 'lib/rql/dsl/comparisons.rb', line 30 def >=(value) Context.new(@model, arel.gteq(value)) end |
#end_with?(value) ⇒ Boolean
42 43 44 |
# File 'lib/rql/dsl/comparisons.rb', line 42 def end_with?(value) Context.new(@model, arel.matches("%#{value}", nil, true)) end |
#in?(collection) ⇒ Boolean
50 51 52 53 |
# File 'lib/rql/dsl/comparisons.rb', line 50 def in?(collection) collection = collection.is_a?(Array) ? collection : collection.arel Context.new(@model, arel.in(collection)) end |
#include?(value) ⇒ Boolean
46 47 48 |
# File 'lib/rql/dsl/comparisons.rb', line 46 def include?(value) Context.new(@model, arel.matches("%#{value}%", nil, true)) end |
#start_with?(value) ⇒ Boolean
38 39 40 |
# File 'lib/rql/dsl/comparisons.rb', line 38 def start_with?(value) Context.new(@model, arel.matches("#{value}%", nil, true)) end |