lib/livery/presenter.rb in livery-0.2.0 vs lib/livery/presenter.rb in livery-0.3.0

- old
+ new

@@ -73,21 +73,31 @@ end end end def t(*args) - I18n.t(ActiveSupport::Inflector.underscore(self.class.name) + args.shift, *args) + I18n.t(resolve_i18n_path(args.shift), *args) end def t!(*args) - I18n.t!(ActiveSupport::Inflector.underscore(self.class.name) + args.shift, *args) + I18n.t!(resolve_i18n_path(args.shift), *args) end def to_model raise 'Presenter objects should not be used for forms. Call .resource on this Presenter' end def to_param(*args) @resource.to_param(*args) + end + + private + + def resolve_i18n_path(key) + if key[0] != '.' + key + else + ActiveSupport::Inflector.underscore(self.class.name).tr('/', '.') + key + end end end end