Class: StripeLocal::Charge
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- StripeLocal::Charge
- Includes:
- ObjectAdapter
- Defined in:
- app/models/stripe_local/charge.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create(object) ⇒ Object
19 20 21 |
# File 'app/models/stripe_local/charge.rb', line 19 def create object super normalize( object ) end |
.normalize(attrs) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/stripe_local/charge.rb', line 23 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 |
Instance Method Details
#metadata ⇒ Object
14 15 16 |
# File 'app/models/stripe_local/charge.rb', line 14 def MultiJson.load read_attribute( :metadata ), symbolize_keys: true end |