Sha256: d466d3e2815f8a8fb88ead06918b0bd05db8b8dc7ff9dfb04fcdfc8a61e8d15a
Contents?: true
Size: 690 Bytes
Versions: 2
Compression:
Stored size: 690 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, name)| 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_enum-1.0.0.rc1 | lib/active_enum/storage/i18n_store.rb |
active_enum-1.0.0.pre | lib/active_enum/storage/i18n_store.rb |