Class: Array

Inherits:
Object show all
Defined in:
lib/json_logic/truthy.rb,
lib/core_ext/deep_fetch.rb

Instance Method Summary collapse

Instance Method Details

#deep_fetch(index, default = nil) ⇒ Object



12
13
14
15
16
# File 'lib/core_ext/deep_fetch.rb', line 12

def deep_fetch(index, default = nil)
  indexes = index.to_s.split('.').map(&:to_i)
  value = dig(*indexes) rescue default
  value.nil? ? default : value  # value can be false (Boolean)
end

#falsy?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/json_logic/truthy.rb', line 45

def falsy?
  empty?
end