Class: EnumIsh::DictionaryLookup
- Inherits:
-
Object
- Object
- EnumIsh::DictionaryLookup
- Defined in:
- lib/enum_ish/dictionary_lookup.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(klass, enum, options = {}) ⇒ DictionaryLookup
constructor
A new instance of DictionaryLookup.
Constructor Details
#initialize(klass, enum, options = {}) ⇒ DictionaryLookup
Returns a new instance of DictionaryLookup.
5 6 7 8 9 |
# File 'lib/enum_ish/dictionary_lookup.rb', line 5 def initialize(klass, enum, = {}) @klass = klass @enum = enum @options = end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/enum_ish/dictionary_lookup.rb', line 11 def call i18n = lookup_for(@klass).transform_keys { |k| k.to_s.to_sym } dict = {} if @enum.use?(:accessor) @enum.mapping.each { |k, v| dict[k] = i18n[k] } else @enum.mapping.each { |k, v| dict[v] = i18n[k] } end filter(dict) end |