Sha256: acd033589044b1d162d3a716b106d39ca1a9ec655cfa137d5c634382a371dbc6

Contents?: true

Size: 723 Bytes

Versions: 15

Compression:

Stored size: 723 Bytes

Contents

module Katello
  class HashUtil
    def null_safe_get(hash, default, params)
      # Base case .. if we are down to the last param
      # lets actually try and find the value
      if params.size == 1
        begin
          # If we got back null lets assign the default
          return hash[params[0]] || default
        rescue
          # If we errored out trying to fetch the value we return
          # default value.
          return default
        end
      end
      subhash = hash[params.first]
      # If we don't have a subhash don't try and recurse down
      if !subhash.nil? && !subhash.empty?
        self.null_safe_get(subhash, default, params[1..])
      else
        default
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
katello-4.16.0 app/models/katello/hash_util.rb
katello-4.15.1 app/models/katello/hash_util.rb
katello-4.16.0.rc2 app/models/katello/hash_util.rb
katello-4.16.0.rc1 app/models/katello/hash_util.rb
katello-4.14.3 app/models/katello/hash_util.rb
katello-4.14.2 app/models/katello/hash_util.rb
katello-4.15.0 app/models/katello/hash_util.rb
katello-4.15.0.rc2 app/models/katello/hash_util.rb
katello-4.15.0.rc1 app/models/katello/hash_util.rb
katello-4.14.1 app/models/katello/hash_util.rb
katello-4.14.0 app/models/katello/hash_util.rb
katello-4.14.0.rc3 app/models/katello/hash_util.rb
katello-4.14.0.rc2 app/models/katello/hash_util.rb
katello-4.14.0.rc1.1 app/models/katello/hash_util.rb
katello-4.14.0.rc1 app/models/katello/hash_util.rb