Class: Spree::PaymentMethod::ModelName

Inherits:
ActiveModel::Name
  • Object
show all
Defined in:
app/models/spree/payment_method.rb

Overview

Custom ModelName#human implementation to ensure we don’t refer to subclasses as just “PaymentMethod”

Instance Method Summary collapse

Instance Method Details

#human(options = {}) ⇒ Object

Similar to ActiveModel::Name#human, but skips lookup_ancestors



51
52
53
54
55
56
57
58
59
# File 'app/models/spree/payment_method.rb', line 51

def human(options = {})
  defaults = [
    i18n_key,
    options[:default],
    @human
  ].compact
  options = { scope: [:activerecord, :models], count: 1, default: defaults }.merge!(options.except(:default))
  I18n.translate(defaults.shift, **options)
end