Class: StripeLocal::Plan

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

Class Method Summary collapse

Methods included from SyncPlans

#api_destroy, #synchronize_create, #synchronize_destroy

Class Method Details

.create(object) ⇒ Object



16
17
18
19
20
21
22
# File 'app/models/stripe_local/plan.rb', line 16

def create object
  if found = find_by( id: object[:id] )
    found.update_attributes synced: true
  else
    super normalize object
  end
end

.normalize(attrs) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'app/models/stripe_local/plan.rb', line 24

def normalize attrs
  attrs.each_with_object({}) do |(k,v),h|
    key = case k.to_sym
    when :livemode then h[:synced] = true and next
    when ->(x){ attribute_method? x } then k.to_sym
    else next
    end
    h[key] = v
  end
end