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_json, #distinct_from?, #end_with?, #false?, #ilike?, #in?, #include?, #intersect?, #key?, #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.
763 764 765 766 767 |
# File 'lib/active_record/refined/ast.rb', line 763 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.
761 762 763 |
# File 'lib/active_record/refined/ast.rb', line 761 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
761 762 763 |
# File 'lib/active_record/refined/ast.rb', line 761 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
761 762 763 |
# File 'lib/active_record/refined/ast.rb', line 761 def right @right end |
Instance Method Details
#to_arel(table, model) ⇒ Object
769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/active_record/refined/ast.rb', line 769 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 |