Sha256: 6033a3e8b224a6aa9b5e8c6e6a6d8e01e4e0f6d2bc3c2d488dd24df0c627708d

Contents?: true

Size: 518 Bytes

Versions: 5

Compression:

Stored size: 518 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

5 entries across 5 versions & 1 rubygems

Version Path
soaspec-0.0.5 lib/soaspec/common.rb
soaspec-0.0.4 lib/soaspec/common.rb
soaspec-0.0.3 lib/soaspec/common.rb
soaspec-0.0.2 lib/soaspec/common.rb
soaspec-0.0.1 lib/soaspec/common.rb