Module: StripeLocal::AssociationMethods

Defined in:
lib/stripe_local/association_methods.rb

Instance Method Summary collapse

Instance Method Details

#available_transactionsObject



47
48
49
# File 'lib/stripe_local/association_methods.rb', line 47

def available_transactions
  transactions.available
end

#cardsObject



11
12
13
# File 'lib/stripe_local/association_methods.rb', line 11

def cards
  @cards ||= StripeLocal::Card.where( customer_id: customer.id )
end

#chargesObject



35
36
37
# File 'lib/stripe_local/association_methods.rb', line 35

def charges
  @charges ||= StripeLocal::Charge.where( customer_id: customer.id ).order( created: :desc )
end

#couponObject



23
24
25
# File 'lib/stripe_local/association_methods.rb', line 23

def coupon
  @coupon ||= StripeLocal::Coupon.find_by( id: discount.coupon_id )
end

#customerObject



3
4
5
# File 'lib/stripe_local/association_methods.rb', line 3

def customer
  @customer ||= StripeLocal::Customer.find_by( model_id: id )
end

#discountObject



19
20
21
# File 'lib/stripe_local/association_methods.rb', line 19

def discount
  @discount ||= StripeLocal::Discount.find_by( customer_id: customer.id )
end

#invoicesObject



27
28
29
# File 'lib/stripe_local/association_methods.rb', line 27

def invoices
  @invoices ||= StripeLocal::Invoice.where( customer_id: customer.id ).order( date: :desc )
end


31
32
33
# File 'lib/stripe_local/association_methods.rb', line 31

def paid_invoices
  invoices.paid
end

#pending_transactionsObject



43
44
45
# File 'lib/stripe_local/association_methods.rb', line 43

def pending_transactions
  transactions.pending
end

#planObject



15
16
17
# File 'lib/stripe_local/association_methods.rb', line 15

def plan
  @plan ||= StripeLocal::Plan.find_by( id: subscription.plan_id )
end

#subscriptionObject



7
8
9
# File 'lib/stripe_local/association_methods.rb', line 7

def subscription
  @subscription ||= StripeLocal::Subscription.find_by( customer_id: customer.id )
end

#transactionsObject



39
40
41
# File 'lib/stripe_local/association_methods.rb', line 39

def transactions
  @transactions ||= StripeLocal::Transaction.where( source: charges ).order( created: :desc )
end