module StripeLocal class Customer < ActiveRecord::Base include ObjectAdapter self.primary_key = :id belongs_to :model, inverse_of: :customer, foreign_key: "model_id", class_name: "::#{StripeLocal::model_class}" has_many :cards, inverse_of: :customer, class_name: 'StripeLocal::Card' has_many :invoices, inverse_of: :customer, class_name: 'StripeLocal::Invoice' has_many :charges, inverse_of: :customer, class_name: 'StripeLocal::Charge' has_one :subscription, inverse_of: :customer, class_name: 'StripeLocal::Subscription' has_one :plan, through: :subscription, inverse_of: :members, source: :plan, class_name: 'StripeLocal::Card' class<(x){attribute_method? x} then k.to_sym else next end h[key] = v end end def create_each_card ary ary.each do |card| StripeLocal::Card.create( card.to_hash ) end end def create_subscription object StripeLocal::Subscription.create( object.to_hash ) unless object.nil? end end def metadata MultiJson.load read_attribute( :metadata ), symbolize_keys: true end end #=!=# # ==Database Schema # # string :id # integer :account_balance # string :default_card # boolean :delinquent # string :description # string :email # text :metadata # integer :model_id #=ยก=# end