module Workarea decorate Payment, with: :afterpay do decorated do embeds_one :afterpay, class_name: 'Workarea::Payment::Tender::Afterpay' end def afterpay? afterpay.present? end def set_afterpay(attrs) build_afterpay unless afterpay afterpay.attributes = attrs.slice( :token ) save end def clear_afterpay self.afterpay = nil save end def set_credit_card(*) self.afterpay = nil super end end end