Class: CafeCar::QueryBuilder::Op

Inherits:
Struct
  • Object
show all
Defined in:
lib/cafe_car/query_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(op, rhs) ⇒ Op

Returns a new instance of Op.



6
7
8
# File 'lib/cafe_car/query_builder.rb', line 6

def initialize(op, rhs)
  super(op.to_sym, rhs)
end

Instance Attribute Details

#opObject

Returns the value of attribute op

Returns:

  • (Object)

    the current value of op



5
6
7
# File 'lib/cafe_car/query_builder.rb', line 5

def op
  @op
end

#rhsObject

Returns the value of attribute rhs

Returns:

  • (Object)

    the current value of rhs



5
6
7
# File 'lib/cafe_car/query_builder.rb', line 5

def rhs
  @rhs
end

Instance Method Details

#arel(node) ⇒ Object



13
# File 'lib/cafe_car/query_builder.rb', line 13

def arel(node) = node.public_send(arel_op, rhs)

#arel_opObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/cafe_car/query_builder.rb', line 15

def arel_op
  case op
  when :<  then :lt
  when :>  then :gt
  when :>= then :gteq
  when :<= then :lteq
  when :== then :eq
  else op
  end
end

#flopObject



10
# File 'lib/cafe_car/query_builder.rb', line 10

def flop = op.to_s.tr("<>", "><").to_sym

#mapObject



11
# File 'lib/cafe_car/query_builder.rb', line 11

def map  = Op.new(op, yield(rhs))