Class: ActiveRecord::Refined::AST::JsonContains

Inherits:
Predicate show all
Defined in:
lib/active_record/refined/ast.rb

Overview

JSON containment: whether the document holds what is given.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Predicate

#!, #&, #|

Methods inherited from Node

#as, #asc, #collate, #desc

Constructor Details

#initialize(operand, value) ⇒ JsonContains

Returns a new instance of JsonContains.



1118
1119
1120
1121
# File 'lib/active_record/refined/ast.rb', line 1118

def initialize(operand, value)
  @operand = operand
  @value = value
end

Instance Attribute Details

#operandObject (readonly)

Returns the value of attribute operand.



1116
1117
1118
# File 'lib/active_record/refined/ast.rb', line 1116

def operand
  @operand
end

#valueObject (readonly)

Returns the value of attribute value.



1116
1117
1118
# File 'lib/active_record/refined/ast.rb', line 1116

def value
  @value
end

Instance Method Details

#to_arel(table, model) ⇒ Object



1123
1124
1125
1126
1127
# File 'lib/active_record/refined/ast.rb', line 1123

def to_arel(table, model)
  Dialect.for(model).json_contains(
    to_arel_operand(operand, table, model),
    Arel::Nodes.build_quoted(JSON.generate(value)), model)
end