Module: Arel::JSONPredications

Defined in:
lib/arel/json_predications.rb

Instance Method Summary collapse

Instance Method Details

#cast_as(type) ⇒ Object



22
23
24
# File 'lib/arel/json_predications.rb', line 22

def cast_as(type)
  Arel::Attributes::Cast.new(self, type)
end

#dig(*keys) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/arel/json_predications.rb', line 26

def dig(*keys)
  keys = keys[0] if keys.size == 1 && keys.first.is_a?(Array)
  
  if keys.empty?
    self
  else
    keys.inject(self) { |node, key| Arel::Attributes::Key.new(node, key) }
  end
end

#has_any_key(*keys) ⇒ Object



18
19
20
# File 'lib/arel/json_predications.rb', line 18

def has_any_key(*keys)
  Arel::Nodes::HasAnyKey.new(self, keys)
end

#has_key(key) ⇒ Object



10
11
12
# File 'lib/arel/json_predications.rb', line 10

def has_key(key)
  Arel::Nodes::HasKey.new(self, key)
end

#has_keys(*keys) ⇒ Object



14
15
16
# File 'lib/arel/json_predications.rb', line 14

def has_keys(*keys)
  Arel::Nodes::HasKeys.new(self, keys)
end

#key(key) ⇒ Object Also known as: [], index



4
5
6
# File 'lib/arel/json_predications.rb', line 4

def key(key)
  Arel::Attributes::Key.new(self, key)
end