Class: StripeLocal::Transfer

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ObjectAdapter
Defined in:
app/models/stripe_local/transfer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(object) ⇒ Object



17
18
19
# File 'app/models/stripe_local/transfer.rb', line 17

def create object
  super normalize( object )
end

.normalize(attrs) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/stripe_local/transfer.rb', line 21

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

Instance Method Details

#metadataObject



12
13
14
# File 'app/models/stripe_local/transfer.rb', line 12

def 
  MultiJson.load read_attribute( :metadata ), symbolize_keys: true
end