Sha256: 160c6d311eb0eb5100fd6126f93b94136218315c8cf3bd40fc59b1ccf05bd0dd
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
module StripeLocal class Transfer < ActiveRecord::Base include ObjectAdapter has_one :transaction, as: :source self.primary_key = :id time_writer :date def metadata= so MultiJson.dump so.to_hash end 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 :balance_transaction then :transaction_id when :date then h[:date] = 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 # integer :amount # datetime :date # string :status # string :transaction_id # string :description # text :metadata #=ยก=#>>> end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stripe_local-0.2.1 | app/models/stripe_local/transfer.rb |