Sha256: 94356e626acae528b842775a3deafe4dce4ce95f6850dc5f9612967a71e297fd
Contents?: true
Size: 827 Bytes
Versions: 7
Compression:
Stored size: 827 Bytes
Contents
module Workarea decorate Payment, with: :paypal do decorated do embeds_one :paypal, class_name: 'Workarea::Payment::Tender::Paypal' delegate :paypal_id, to: :paypal, allow_nil: true end def set_paypal(attrs) build_paypal unless paypal paypal.attributes = attrs.slice( :paypal_id, :payer_id, :details, :approved, :direct_payment ) save end def paypal? paypal.present? && paypal.approved? end def set_credit_card(*) self.paypal = nil super end def address addr = super return addr if !paypal? || addr&.valid? Payment::NullAddress.new.tap { |na| na.reference = addr || build_address } end def real_address method(:address).super_method.call end end end
Version data entries
7 entries across 7 versions & 1 rubygems