Class: ActiveRecord::Refined::AST::JsonPath

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

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 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

#as, #asc, #collate, #desc

Constructor Details

#initialize(operand, path, json_value: true) ⇒ JsonPath

Returns a new instance of JsonPath.



1011
1012
1013
1014
1015
# File 'lib/active_record/refined/ast.rb', line 1011

def initialize(operand, path, json_value: true)
  @operand = operand
  @path = check_steps(path, "dig")
  @json_value = json_value
end

Instance Attribute Details

#operandObject (readonly)

Returns the value of attribute operand.



1009
1010
1011
# File 'lib/active_record/refined/ast.rb', line 1009

def operand
  @operand
end

#pathObject (readonly)

Returns the value of attribute path.



1009
1010
1011
# File 'lib/active_record/refined/ast.rb', line 1009

def path
  @path
end

Instance Method Details

#json_value?Boolean

Returns:

  • (Boolean)


1017
1018
1019
# File 'lib/active_record/refined/ast.rb', line 1017

def json_value?
  @json_value
end

#to_arel(table, model) ⇒ Object



1021
1022
1023
1024
1025
# File 'lib/active_record/refined/ast.rb', line 1021

def to_arel(table, model)
  Dialect.for(model).json_path(
    to_arel_operand(operand, table, model),
    dollar_path, steps_array, json_value?, model)
end