Module: Spree::V2::Storefront::PaymentMethodSerializerDecorator

Defined in:
app/serializers/spree/v2/storefront/payment_method_serializer_decorator.rb

Class Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/serializers/spree/v2/storefront/payment_method_serializer_decorator.rb', line 5

def self.prepended(base)
  base.attribute :icon_name do |payment_method|
    return nil if payment_method.preferences.blank?
  
    payment_method.preferences[:icon_name]
  end

  base.attribute :payment_option do |payment_method|
    pref = payment_method.preferences

    pref.blank? || pref[:payment_option].blank? ? payment_method.method_type : pref[:payment_option]
  end
end