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?, #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.
898 899 900 901 902 |
# File 'lib/active_record/refined/ast.rb', line 898 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.
896 897 898 |
# File 'lib/active_record/refined/ast.rb', line 896 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
896 897 898 |
# File 'lib/active_record/refined/ast.rb', line 896 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
896 897 898 |
# File 'lib/active_record/refined/ast.rb', line 896 def right @right end |
Instance Method Details
#to_arel(table, model) ⇒ Object
904 905 906 907 908 909 910 911 912 913 914 915 |
# File 'lib/active_record/refined/ast.rb', line 904 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 |