Class: BraintreeRails::Transactions

Inherits:
SimpleDelegator
  • Object
show all
Includes:
CollectionAssociation
Defined in:
lib/braintree_rails/transactions.rb

Instance Method Summary collapse

Methods included from CollectionAssociation

included

Constructor Details

#initialize(belongs_to) ⇒ Transactions

Returns a new instance of Transactions.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/braintree_rails/transactions.rb', line 5

def initialize(belongs_to)
  case belongs_to
  when BraintreeRails::Customer
    @customer = belongs_to
  when BraintreeRails::CreditCard
    @credit_card = belongs_to
  when BraintreeRails::Subscription
    @subscription = belongs_to
    self.singleton_class.not_supported_apis(:build)
  end
  super([])
end

Instance Method Details

#default_optionsObject



18
19
20
21
22
23
24
25
26
# File 'lib/braintree_rails/transactions.rb', line 18

def default_options
  if @credit_card.present?
    {:credit_card => @credit_card}
  elsif @customer.present?
    {:customer => @customer, :credit_card => @customer.default_credit_card}
  else
    {}
  end
end