Sha256: 6d5fcbf68a5ad33256399155753e17ae8968f76e943bb3cb59bafa9bfc1513ae

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 Bytes

Contents

module HashBrowns
  module OverviewHelpers

    def overview_fields(type)
      type = type.to_s
      fields = HashBrowns.conf.key_fields[type]
      return [] unless fields
      puts "calling field parser now"
      return field_parser(type, fields, [])
    end

    def field_parser(k, v, path)
      k, path = k.to_s, path.map{|p| p.to_s}
      return "#{k} had nil value at #{path.inspect}" if v.nil?
      return v.map{|i| [display_name(i, path.last), path + [i]] } if k == "values"
      return v.map{|ki, vi| field_parser(ki, vi, path + [k]) }.inject(:+)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hashbrowns-0.1.5 lib/hashbrowns/helpers/overview_helpers.rb
hashbrowns-0.1.4 lib/hashbrowns/helpers/overview_helpers.rb
hashbrowns-0.1.3 lib/hashbrowns/helpers/overview_helpers.rb