Sha256: cde30100c803ebe81415814dab2a43aa71d04563e24da2c23efeeadd65fc7a39

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

module Cupcakinator

  # known configuration variables
  # method
  # dir
  # file
  # root_key
  # allow_missing
  class Config < Hash
    include Hashie::Extensions::MethodAccess
    include Hashie::Extensions::Coercion

    coerce_value Hash, Config

    # @param [Hash] h
    # @return Cupcakinator::Config
    def initialize(h={})
      super
      h.each_pair do |k,v|
        self[k] = v
      end
    end


    # @return [Hash] returns uncoerced Hash
    def to_h
      convert_config_to_hash(self.dup)
    end


    private


    def convert_config_to_hash(c)
      h = Hash.new
      c.each_pair{ |key, value| Config === value ? h[key] = convert_config_to_hash(value) : h[key] = value }
      h
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cupcakinator-2.0.0 lib/cupcakinator/config.rb