Module: SpreeNpAtobarai::PaymentDecorator

Defined in:
app/models/spree_np_atobarai/payment_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/models/spree_np_atobarai/payment_decorator.rb', line 3

def self.prepended(base)
  base.attribute :invoice_sending, :string
  base.enum :invoice_sending, { postal: 'postal', email: 'email' }, prefix: :invoice_sending

  base.validates :invoice_sending, presence: true,
                                   if: ->(payment) { payment.payment_method.is_a?(Spree::PaymentMethod::NpAtobarai) }

  base.define_singleton_method(:human_invoice_sending_name) do |invoice_sending_type|
    return if invoice_sending_type.blank?

    I18n.t("activerecord.attributes.spree/payment.invoice_sendings.#{invoice_sending_type}")
  end
end

Instance Method Details

#human_invoice_sending_nameObject



17
18
19
# File 'app/models/spree_np_atobarai/payment_decorator.rb', line 17

def human_invoice_sending_name
  self.class.human_invoice_sending_name(invoice_sending)
end