Sha256: 05d6b741e23daa26b40ea83e84d7414da193ed35edb9c173d3b9b33773cc9841

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

module SmartAttr
  class ConfigHash

    attr_reader :config_values_map

    def initialize(*args)
      @config_hash = args.extract_options!

      @config_values_map = {}

      @config_hash.each do |_key, _config|
        @config_values_map[_config[:value]] = _config.merge(key: _key)
      end
    end

    def item(value)
      @config_values_map[value]
    end

    def keys
      @config_hash.keys
    end

    def [](key)
      @config_hash[key]
    end

    # TODO
    # Add spec
    # def method_missing
    #   # delegate to Hash
    # end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smart_attr-0.2.0 lib/smart_attr/config_hash.rb
smart_attr-0.1.1 lib/smart_attr/config_hash.rb