Sha256: f63ebc9c6f6cf85232e30e0bf86dd0f4600e25c12a2053edf319e5d7965228f9
Contents?: true
Size: 687 Bytes
Versions: 9
Compression:
Stored size: 687 Bytes
Contents
require 'i18n' module ActiveEnum module Storage class I18nStore < MemoryStore def get_by_id(id) row = _values.assoc(id) [ id, translate(row[1]), row[2] ].compact if row end def get_by_name(name) row = _values.rassoc(name.to_s) [ row[0], translate(row[1]), row[2] ].compact if row end def values _values.map { |(id, _)| get_by_id(id) } end def i18n_scope @i18n_scope ||= [ :active_enum ] + @enum.name.split("::").map { |nesting| nesting.underscore.to_sym } end def translate(key) I18n.translate key, :scope => i18n_scope, :default => key end end end end
Version data entries
9 entries across 9 versions & 1 rubygems