Sha256: 4f9def7317bcd4a82ee970e0825f304a190ba4a3658ffc776561dfc8ab2eeb6e

Contents?: true

Size: 542 Bytes

Versions: 4

Compression:

Stored size: 542 Bytes

Contents

class Hash

  # Loop through each item within a key within a Hash if the key exists
  # @param [Key] Key within hash to iterate through
  def each_if_not_null(key)
    case key.class.to_s
    when 'String'
      if self[key]
        self[key].each do |list_item|
          yield(list_item)
        end
      end
    when 'Array'
      if self[key[0]]
        if self[key[0]][key[1]]
          self[key[0]][key[1]].each do |list_item|
            yield(list_item)
          end
        end
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
soaspec-0.0.9 lib/soaspec/common.rb
soaspec-0.0.8 lib/soaspec/common.rb
soaspec-0.0.7 lib/soaspec/common.rb
soaspec-0.0.6 lib/soaspec/common.rb