Class: StripeLocal::Card

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

Class Method Summary collapse

Class Method Details

.create(attrs_hash) ⇒ Object



9
10
11
# File 'app/models/stripe_local/card.rb', line 9

def create attrs_hash
  super normalize( attrs_hash )
end

.normalize(hash) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/stripe_local/card.rb', line 13

def normalize hash
  hash.each_with_object({}) do |(k,v),h|
    key = case k.to_sym
    when :customer then :customer_id
    when :type     then :brand
    when ->(x){attribute_method? x} then k.to_sym
    else next
    end
    h[key] = v
  end
end