Sha256: 91c15129dc4fe7cf6a52cca6d5f1832031386903b49755138be6d8f0b4749d34
Contents?: true
Size: 736 Bytes
Versions: 11
Compression:
Stored size: 736 Bytes
Contents
module StripeLocal module SyncPlans extend ActiveSupport::Concern included do after_create :synchronize_create private :synchronize_create, :synchronize_destroy end module ClassMethods def delete id, destroy_remote = true if super( id ) synchronize_destroy( id ) if destroy_remote == true end end end def synchronize_create hash = self.attributes unless !!hash.delete( :synced ) Stripe::Plan.create hash #TODO: handle asynchronously end end def synchronize_destroy id begin Stripe::Plan.delete id rescue Stripe::Error end end def api_destroy plan Plan.destroy end end end
Version data entries
11 entries across 11 versions & 1 rubygems