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 #=!=>>> # ~~ # t.string :id # t.integer :account_balance # t.string :default_card # t.boolean :delinquent # t.string :description # t.string :email # t.text :metadata # t.integer :model_id # t.timestamps #=ยก=>>> end end