Class: ArelOperators::Finder

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

Defined Under Namespace

Classes: Comparators

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arel_table, operation = nil) ⇒ Finder

Returns a new instance of Finder.



6
7
8
9
10
# File 'lib/arel_operators/finder.rb', line 6

def initialize(arel_table, operation=nil)
  @table = arel_table
  @arel = operation
  @table.attributes.each { |a| define_attribute_method a.name }
end

Instance Attribute Details

#arelObject (readonly)

Returns the value of attribute arel.



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

def arel
  @arel
end

#tableObject (readonly)

Returns the value of attribute table.



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

def table
  @table
end

Instance Method Details

#&(other) ⇒ Object



24
25
26
27
# File 'lib/arel_operators/finder.rb', line 24

def &(other)
  other = other.arel if other.respond_to?(:arel)
  Finder.new(table, arel.and(other))
end

#-@Object



37
38
39
# File 'lib/arel_operators/finder.rb', line 37

def -@
  Finder.new(table, Arel::Predicates::Not.new(arel))
end

#|(other) ⇒ Object



19
20
21
22
# File 'lib/arel_operators/finder.rb', line 19

def |(other)
  other = other.arel if other.respond_to?(:arel)
  Finder.new(table, arel.or(other))
end