Class: Ashmont::SubscribedCustomer

Inherits:
Customer
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ashmont/subscribed_customer.rb

Constant Summary collapse

CUSTOMER_ATTRIBUTES =
[:cardholder_name, :email, :number,
:expiration_month, :expiration_year, :cvv,
:street_address, :extended_address, :locality,
:region, :postal_code, :country_name]

Constants inherited from Customer

Customer::ADDRESS_ATTRIBUTES, Customer::BILLING_ATTRIBUTES, Customer::CREDIT_CARD_ATTRIBUTES

Instance Attribute Summary

Attributes inherited from Customer

#token

Instance Method Summary collapse

Methods inherited from Customer

#billing_email, #cardholder_name, #confirm, #country_name, #credit_card, #credit_cards, #delete, #expiration_month, #expiration_year, #extended_address, #has_billing_info?, #last_4, #locality, #payment_method_token, #paypal_account, #paypal_accounts, #postal_code, #primary_payment_account, #primary_payment_method, #region, #street_address

Constructor Details

#initialize(customer, subscription) ⇒ SubscribedCustomer

Returns a new instance of SubscribedCustomer.



13
14
15
16
17
# File 'lib/ashmont/subscribed_customer.rb', line 13

def initialize(customer, subscription)
  super(customer)
  @customer = customer
  @subscription = subscription
end

Instance Method Details

#errorsObject



30
31
32
# File 'lib/ashmont/subscribed_customer.rb', line 30

def errors
  super.to_hash.merge(@subscription.errors.to_hash)
end

#save(attributes) ⇒ Object



26
27
28
# File 'lib/ashmont/subscribed_customer.rb', line 26

def save(attributes)
  apply_customer_changes(attributes) && ensure_subscription_active && apply_subscription_changes(attributes)
end

#subscription_tokenObject



22
23
24
# File 'lib/ashmont/subscribed_customer.rb', line 22

def subscription_token
  @subscription.token
end