Sha256: c04f0b4f24248baedc9e5433a2aa88c16bbed7c00b4187998963dad601dd2807
Contents?: true
Size: 1.32 KB
Versions: 5
Compression:
Stored size: 1.32 KB
Contents
module MyMoip class PaymentMethods include ActiveModel::Validations attr_accessor :payment_slip, :credit_card, :debit, :debit_card, :financing, :moip_wallet validates_inclusion_of :payment_slip, :credit_card, :debit, :debit_card, :financing, :moip_wallet, in: [true, false] def initialize(attrs = {}) self.payment_slip = true self.credit_card = true self.debit = true self.debit_card = true self.financing = true self.moip_wallet = true attrs.each do |attr, value| public_send(:"#{attr}=", value) end end def to_xml(root = nil) if root.nil? xml = "" root ||= Builder::XmlMarkup.new(target: xml) end if not using_all? root.FormaPagamento('BoletoBancario') if payment_slip root.FormaPagamento('CartaoDeCredito') if credit_card root.FormaPagamento('DebitoBancario') if debit root.FormaPagamento('CartaoDeDebito') if debit_card root.FormaPagamento('FinanciamentoBancario') if financing root.FormaPagamento('CarteiraMoIP') if moip_wallet end xml end def using_all? payment_slip and credit_card and debit and debit_card and financing and moip_wallet end end end
Version data entries
5 entries across 5 versions & 2 rubygems