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.
Constant Summary collapse
- NODES =
{ :& => Arel::Nodes::BitwiseAnd, :| => Arel::Nodes::BitwiseOr, :<< => Arel::Nodes::BitwiseShiftLeft, :>> => Arel::Nodes::BitwiseShiftRight, }.freeze
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.
1322 1323 1324 1325 1326 |
# File 'lib/active_record/refined/ast.rb', line 1322 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.
1320 1321 1322 |
# File 'lib/active_record/refined/ast.rb', line 1320 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
1320 1321 1322 |
# File 'lib/active_record/refined/ast.rb', line 1320 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
1320 1321 1322 |
# File 'lib/active_record/refined/ast.rb', line 1320 def right @right end |
Instance Method Details
#to_arel(table, model) ⇒ Object
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 |
# File 'lib/active_record/refined/ast.rb', line 1328 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 |