Class: ActiveRecord::Refined::AST::Bitwise
- Includes:
- Arithmetics, BitwiseOperands, Predications
- Defined in:
- lib/active_record/refined/ast.rb
Overview
SQL's bitwise operators. Each parenthesises itself, which is what keeps Ruby's grouping: PostgreSQL gives & and | the same precedence and reads a | b & c from the left, where Ruby reads the & first.
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(left, operator, right) ⇒ Bitwise
constructor
A new instance of Bitwise.
- #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(left, operator, right) ⇒ Bitwise
Returns a new instance of Bitwise.
1432 1433 1434 1435 1436 |
# File 'lib/active_record/refined/ast.rb', line 1432 def initialize(left, operator, right) @left = left @operator = operator @right = check_operand(right, operator) end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
1430 1431 1432 |
# File 'lib/active_record/refined/ast.rb', line 1430 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
1430 1431 1432 |
# File 'lib/active_record/refined/ast.rb', line 1430 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
1430 1431 1432 |
# File 'lib/active_record/refined/ast.rb', line 1430 def right @right end |
Instance Method Details
#to_arel(table, model) ⇒ Object
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
# File 'lib/active_record/refined/ast.rb', line 1438 def to_arel(table, model) check_not_boolean(left, operator, model) check_not_boolean(right, operator, model) arel_left = to_arel_operand(left, table, model) arel_right = to_arel_argument(right, table, model) Arel::Nodes::Grouping.new( if operator == :^ xor(arel_left, arel_right, model) else NODES.fetch(operator).new(arel_left, arel_right) end) end |