Class: ArelOperators::Finder::Comparators

Inherits:
Object
  • Object
show all
Defined in:
lib/arel_operators/finder/comparators.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(finder, field) ⇒ Comparators

Returns a new instance of Comparators.



4
5
6
7
# File 'lib/arel_operators/finder/comparators.rb', line 4

def initialize(finder, field)
  @finder = finder
  @field = finder.table[field]
end

Class Method Details

.convert_to_arel(operation, arel_method) ⇒ Object



9
10
11
12
13
14
# File 'lib/arel_operators/finder/comparators.rb', line 9

def self.convert_to_arel(operation, arel_method)
  define_method(operation) do |other|
    arel_clause =  @field.send(arel_method, other)
    ArelOperators::Finder.new(@finder.table, arel_clause)
  end
end

Instance Method Details

#nil?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/arel_operators/finder/comparators.rb', line 16

def nil?
  self == nil
end