Class: ActiveRecord::Refined::AST::Operation
- Includes:
- Arithmetics, Predications
- Defined in:
- lib/active_record/refined/ast.rb
Overview
Escape hatch for operators without a spelling of their own, the way fn is for functions. The operator is emitted as written -- whether the adapter has it is the caller's assertion, as fn's names are -- and the values ride as quoted literals, so on PostgreSQL an untyped one takes the type of the operand beside it.
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
-
#initialize(operator, left, right) ⇒ Operation
constructor
A new instance of Operation.
- #to_arel(table, model) ⇒ Object
Methods included from Arithmetics
#&, #*, #+, #-, #/, #<<, #>>, #^, #|, #~
Methods included from Predications
#!=, #!~, #<, #<=, #==, #=~, #>, #>=, #between?, #bury, #casecmp?, #contains?, #dig, #dig_text, #distinct_from?, #end_with?, #except, #false?, #ilike?, #in?, #include?, #intersect?, #key?, #keys, #like?, #member?, #not_between?, #not_distinct_from?, #not_false?, #not_ilike?, #not_in?, #not_like?, #not_null?, #not_true?, #null?, #start_with?, #subset?, #superset?, #true?, #when
Methods inherited from Node
Constructor Details
#initialize(operator, left, right) ⇒ Operation
Returns a new instance of Operation.
1685 1686 1687 1688 1689 |
# File 'lib/active_record/refined/ast.rb', line 1685 def initialize(operator, left, right) @operator = AST.check_name(operator, OPERATOR, "operator").to_s @left = check_side(left) @right = check_side(right) end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
1683 1684 1685 |
# File 'lib/active_record/refined/ast.rb', line 1683 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
1683 1684 1685 |
# File 'lib/active_record/refined/ast.rb', line 1683 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
1683 1684 1685 |
# File 'lib/active_record/refined/ast.rb', line 1683 def right @right end |
Instance Method Details
#to_arel(table, model) ⇒ Object
1691 1692 1693 1694 1695 |
# File 'lib/active_record/refined/ast.rb', line 1691 def to_arel(table, model) Arel::Nodes::Grouping.new( Arel::Nodes::InfixOperation.new( operator, side(left, table, model), side(right, table, model))) end |