Class: Ardm::Query::Operator

Inherits:
Object
  • Object
show all
Extended by:
Equalizer
Defined in:
lib/ardm/query/operator.rb

Constant Summary collapse

OPERATORS =
{
  # DM      => ARel
  :eql      => :eq,
  :not      => :not_eq,
  :in       => :in,
  :gt       => :gt,
  :gte      => :gteq,
  :lt       => :lt,
  :lte      => :lteq,
  :like     => :matches,
  :not_like => :does_not_match,
  :regexp   => :regexp,
}
ORDERS =
{
  :asc  => :asc,
  :desc => :desc,
}
ALL =
OPERATORS.merge(ORDERS)
FOR_ARRAY =
{
  :eq     => :in,
  :not_eq => :not_in
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Equalizer

equalize

Instance Attribute Details

#operatorObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/ardm/query/operator.rb', line 34

def operator
  @operator
end

#targetObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/ardm/query/operator.rb', line 31

def target
  @target
end

Instance Method Details

#for_arrayObject



46
47
48
# File 'lib/ardm/query/operator.rb', line 46

def for_array
  FOR_ARRAY[operator]
end

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/ardm/query/operator.rb', line 37

def inspect
  "#<#{self.class.name} #{target.inspect}.#{operator.inspect}>"
end

#to_arel(relation, value) ⇒ Object



50
51
52
# File 'lib/ardm/query/operator.rb', line 50

def to_arel(relation, value)
  Ardm::Query::Expression.new(relation, target, self, value)
end