Class: ActiveRecord::Refined::AST::JsonExcept

Inherits:
Node
  • Object
show all
Includes:
JsonComparable, JsonSteps, Predications
Defined in:
lib/active_record/refined/ast.rb

Overview

Keys taken out of a JSON document. PostgreSQL subtracts them, the other two remove a path apiece.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JsonComparable

#between?, #in?, #not_between?, #not_in?, #~

Methods included from JsonSteps

#check_steps, #dollar_path, #dollar_step, #escape_step, #steps_array

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

#as, #asc, #collate, #desc

Constructor Details

#initialize(operand, keys) ⇒ JsonExcept

Returns a new instance of JsonExcept.



1080
1081
1082
1083
# File 'lib/active_record/refined/ast.rb', line 1080

def initialize(operand, keys)
  @operand = operand
  @keys = check_keys(keys)
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



1078
1079
1080
# File 'lib/active_record/refined/ast.rb', line 1078

def keys
  @keys
end

#operandObject (readonly)

Returns the value of attribute operand.



1078
1079
1080
# File 'lib/active_record/refined/ast.rb', line 1078

def operand
  @operand
end

Instance Method Details

#json_value?Boolean

Returns:

  • (Boolean)


1085
1086
1087
# File 'lib/active_record/refined/ast.rb', line 1085

def json_value?
  true
end

#to_arel(table, model) ⇒ Object



1089
1090
1091
1092
1093
1094
# File 'lib/active_record/refined/ast.rb', line 1089

def to_arel(table, model)
  Dialect.for(model).json_remove(
    to_arel_operand(operand, table, model),
    keys.map { |key| "$#{dollar_step(key)}" },
    steps_array(keys), model)
end