Class: ActiveRecord::QueryMethods::WhereIsArel

Inherits:
Object
  • Object
show all
Defined in:
lib/where-is-rails/where-is-rails.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arel_field) ⇒ WhereIsArel

Returns a new instance of WhereIsArel.



10
11
12
# File 'lib/where-is-rails/where-is-rails.rb', line 10

def initialize(arel_field)
  self.arel_field = arel_field
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, params = {}) ⇒ Object



47
48
49
50
51
# File 'lib/where-is-rails/where-is-rails.rb', line 47

def method_missing(method_name, params = {})
  return arel_field.send(method_name, params) if arel_field.respond_to? method_name

  super
end

Instance Attribute Details

#arel_field ⇒ Object

Returns the value of attribute arel_field.



8
9
10
# File 'lib/where-is-rails/where-is-rails.rb', line 8

def arel_field
  @arel_field
end

Instance Method Details

#!=(other) ⇒ Object



34
35
36
# File 'lib/where-is-rails/where-is-rails.rb', line 34

def !=(other)
  arel_field.not_eq parse_other(other)
end

#<(other) ⇒ Object



22
23
24
# File 'lib/where-is-rails/where-is-rails.rb', line 22

def <(other)
  arel_field.lt parse_other(other)
end

#<=(other) ⇒ Object



26
27
28
# File 'lib/where-is-rails/where-is-rails.rb', line 26

def <=(other)
  arel_field.lteq parse_other(other)
end

#==(other) ⇒ Object



30
31
32
# File 'lib/where-is-rails/where-is-rails.rb', line 30

def ==(other)
  arel_field.eq parse_other(other)
end

#=~(other) ⇒ Object



38
39
40
41
# File 'lib/where-is-rails/where-is-rails.rb', line 38

def =~(other)
  other = other.source if other.is_a?(Regexp)
  arel_field.matches_regexp parse_other(other)
end

#>(other) ⇒ Object



14
15
16
# File 'lib/where-is-rails/where-is-rails.rb', line 14

def >(other)
  arel_field.gt parse_other(other)
end

#>=(other) ⇒ Object



18
19
20
# File 'lib/where-is-rails/where-is-rails.rb', line 18

def >=(other)
  arel_field.gteq parse_other(other)
end

#in?(other) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/where-is-rails/where-is-rails.rb', line 43

def in?(other)
  arel_field.eq_any parse_other(other)
end