Class: EnumIsh::Dictionary
- Inherits:
-
Object
- Object
- EnumIsh::Dictionary
- Defined in:
- lib/enum_ish/builder.rb
Instance Method Summary collapse
-
#initialize(klass) ⇒ Dictionary
constructor
A new instance of Dictionary.
- #load(attr, enum, config, options) ⇒ Object
Constructor Details
#initialize(klass) ⇒ Dictionary
Returns a new instance of Dictionary.
98 99 100 |
# File 'lib/enum_ish/builder.rb', line 98 def initialize(klass) @klass = klass end |
Instance Method Details
#load(attr, enum, config, options) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/enum_ish/builder.rb', line 102 def load(attr, enum, config, ) dict = load_i18n(attr, enum, ) translated = enum.map { |k, v| dict[k] ? [k, dict[k]] : [k, v.to_s] }.to_h translated = translated.map { |k, v| [enum[k], v] }.to_h unless config[:accessor] translated end |