Class: SmartAttr::ConfigHash

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_attr/config_hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ConfigHash

Returns a new instance of ConfigHash.



6
7
8
9
10
11
12
13
14
# File 'lib/smart_attr/config_hash.rb', line 6

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

Instance Attribute Details

#config_values_mapObject (readonly)

Returns the value of attribute config_values_map.



4
5
6
# File 'lib/smart_attr/config_hash.rb', line 4

def config_values_map
  @config_values_map
end

Instance Method Details

#[](key) ⇒ Object



24
25
26
# File 'lib/smart_attr/config_hash.rb', line 24

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

#item(value) ⇒ Object



16
17
18
# File 'lib/smart_attr/config_hash.rb', line 16

def item(value)
  @config_values_map[value]
end

#keysObject



20
21
22
# File 'lib/smart_attr/config_hash.rb', line 20

def keys
  @config_hash.keys
end