Sha256: b3c4f28f239aef6ba76c726bf3772bd2f2c5204dcbf628a9cf869ae904380d3e

Contents?: true

Size: 641 Bytes

Versions: 23

Compression:

Stored size: 641 Bytes

Contents

Hash.class_eval do

  def dig_for_array(*path)
    (v = self.dig(*path)).is_a?(Array) ? v : nil
  end

  def dig_for_boolean(*path)
    (v = self.dig(*path)).to_s.upcase.eql?("TRUE") ? true : nil
  end

  def dig_for_datetime(*path)
    self.dig(*path).to_datetime rescue nil
  end

  def dig_for_decimal(*path)
    (v = self.dig(*path).to_f) != 0.0 ? v : nil
  end

  def dig_for_hash(*path)
    (v = self.dig(*path)).is_a?(Hash) ? v : nil
  end

  def dig_for_integer(*path)
    (v = self.dig(*path).to_i) != 0 ? v : nil
  end

  def dig_for_string(*path)
    (v = self.dig(*path)).to_s.present? ? (v.eql?("0") ? nil : v) : nil
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
realogy-0.6.8 lib/realogy/app/models/hash.rb
realogy-0.6.7 lib/realogy/app/models/hash.rb
realogy-0.6.6 lib/realogy/app/models/hash.rb
realogy-0.6.5 lib/realogy/app/models/hash.rb
realogy-0.6.4 lib/realogy/app/models/hash.rb
realogy-0.6.3 lib/realogy/app/models/hash.rb
realogy-0.6.2 lib/realogy/app/models/hash.rb
realogy-0.6.1 lib/realogy/app/models/hash.rb
realogy-0.6.0 lib/realogy/app/models/hash.rb
realogy-0.5.9 lib/realogy/app/models/hash.rb
realogy-0.5.4 lib/realogy/app/models/hash.rb
realogy-0.5.3 lib/realogy/app/models/hash.rb
realogy-0.5.2 lib/realogy/app/models/hash.rb
realogy-0.5.1 lib/realogy/app/models/hash.rb
realogy-0.5.0 lib/realogy/app/models/hash.rb
realogy-0.4.9 lib/realogy/app/models/hash.rb
realogy-0.4.8 lib/realogy/app/models/hash.rb
realogy-0.4.7 lib/realogy/app/models/hash.rb
realogy-0.4.6 lib/realogy/app/models/hash.rb
realogy-0.4.5 lib/realogy/app/models/hash.rb