Sha256: 8d453cd8a0c6793c3741bf720db1f15a4b5f0f4b65d34982538da8c57b726e11

Contents?: true

Size: 1.36 KB

Versions: 30

Compression:

Stored size: 1.36 KB

Contents

module PaymentMethodHelper

  def next_payment_processing_action(order)
    if pm = order.payment_method
      call_engineized_method(pm, :next_payment_processing_action, order)
    end
  end

  def order_show_extra_info(order)
    if pm = order.payment_method
      call_engineized_method(pm, :order_show_extra_info, order)
    end
  end

  def available_payment_options_icons
    PaymentMethod.order('id desc').map do |pm|
      call_engineized_method(pm, :available_payment_options_icons)
    end.compact.flatten
  end

  def icon_for_order_payment(order)
    if pm = order.payment_method
      call_engineized_method(pm, :icon_for_order_payment, order)
    end
  end

  def payment_info_for_buyer(order)
    if pm = order.payment_method
      call_engineized_method(pm, :payment_info_for_buyer, order)
    end
  end

  def nimbleshop_crud_form(payment_method)
    call_engineized_method(payment_method, :crud_form)
  end

  def engineized_name(payment_method, method_name)
    "nimbleshop_#{payment_method.demodulized_underscore}_#{method_name}".intern
  end

  def call_engineized_method(payment_method, method_name, *args)
    method_name_in_engine = engineized_name(payment_method, method_name)
    if self.respond_to?(method_name_in_engine)
      if args.any?
        self.send(method_name_in_engine, *args)
      else
        self.send(method_name_in_engine)
      end
    end
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
nimbleshop_core-0.0.23 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.21 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.20 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.19 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.17 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.16 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.15 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.14 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.14.rc2 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.14.rc1 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.13 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.12 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.11 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.10 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.9 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.8 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.7 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.5 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.4.beta1 app/helpers/payment_method_helper.rb
nimbleshop_core-0.0.4 app/helpers/payment_method_helper.rb