Sha256: c7415c06606ec728a2a7521cf78d785646720c56469070950410222ff0a21b90
Contents?: true
Size: 1.52 KB
Versions: 4
Compression:
Stored size: 1.52 KB
Contents
module StripeLocal class Charge < ActiveRecord::Base include ObjectAdapter belongs_to :card, inverse_of: :charges belongs_to :customer, inverse_of: :charges has_one :transaction, as: :source has_one :invoice, inverse_of: :charge self.primary_key = :id time_writer :created def metadata MultiJson.load read_attribute( :metadata ), symbolize_keys: true end class<<self def create object super normalize( object ) end def normalize attrs attrs.each_with_object({}) do |(k,v),h| key = case k.to_sym when :customer then :customer_id when :invoice then :invoice_id when :balance_transaction then :transaction_id when :card then h[:card_id] = v.id and next when :created then h[:created] = Time.at(v) and next when :metadata then h[:metadata] = MultiJson.dump( v.to_hash ) and next when ->(x){attribute_method? x} then k.to_sym else next end h[key] = v end end end #=!=#>>> # string :id # string :card_id # string :customer_id # string :invoice_id # string :transaction_id # integer :amount # boolean :captured # boolean :refunded # boolean :paid # datetime :created # string :currency # integer :amount_refunded # string :description # string :failure_code # string :failure_message # text :metadata #=ยก=#>>> end end
Version data entries
4 entries across 4 versions & 1 rubygems