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

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

Overview

Reading inside a JSON document, which is what Predications#dig and Predications#dig_text build. Every adapter can do it and no two spell it alike: PostgreSQL walks an array of steps, SQLite has the operators with a $ path, and MySQL has the functions -- which is what this uses for that family, since MariaDB answers to the same adapter and has no -> at all.

The path is turned into a string either way, so a key with a space or a quote in it travels as itself rather than having to be refused. What a dug value compares with is JsonComparable's to say.

Instance Method Summary collapse

Methods included from JsonComparable

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

Methods included from Arithmetics

#&, #*, #+, #-, #/, #<<, #>>, #^, #bitwise_and, #bitwise_not, #bitwise_or, #bitwise_xor, #|, #~

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.



1156
1157
1158
1159
1160
# File 'lib/active_record/refined/ast.rb', line 1156

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