Class: Reji::PaymentMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/reji/payment_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, payment_method) ⇒ PaymentMethod

Returns a new instance of PaymentMethod.



5
6
7
8
9
10
11
12
# File 'lib/reji/payment_method.rb', line 5

def initialize(owner, payment_method)
  if owner.stripe_id != payment_method.customer
    raise Reji::InvalidPaymentMethodError.invalid_owner(payment_method, owner)
  end

  @owner = owner
  @payment_method = payment_method
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key) ⇒ Object

Dynamically get values from the Stripe PaymentMethod.



28
29
30
# File 'lib/reji/payment_method.rb', line 28

def method_missing(key)
  @payment_method[key]
end

Instance Attribute Details

#ownerObject (readonly)

Get the Stripe model instance.



20
21
22
# File 'lib/reji/payment_method.rb', line 20

def owner
  @owner
end

Instance Method Details

#as_stripe_payment_methodObject

Get the Stripe PaymentMethod instance.



23
24
25
# File 'lib/reji/payment_method.rb', line 23

def as_stripe_payment_method
  @payment_method
end

#deleteObject

Delete the payment method.



15
16
17
# File 'lib/reji/payment_method.rb', line 15

def delete
  @owner.remove_payment_method(@payment_method)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/reji/payment_method.rb', line 32

def respond_to_missing?(method_name, include_private = false)
  super
end