Sha256: a199ee2eb732851ced43295398666dfc059299db2e766f6945103e58b49a2787

Contents?: true

Size: 593 Bytes

Versions: 5

Compression:

Stored size: 593 Bytes

Contents

class StripeModelCallbacks::TaxRate::UpdatedService < StripeModelCallbacks::BaseEventService
  def perform
    tax_rate.assign_from_stripe(object)

    if tax_rate.save
      create_activity if event
      succeed! tax_rate
    else
      fail! tax_rate.errors.full_messages
    end
  end

private

  def create_activity
    case event.type
    when "tax_rate.created"
      tax_rate.create_activity :created
    when "tax_rate.updated"
      tax_rate.create_activity :updated
    end
  end

  def tax_rate
    @tax_rate ||= StripeTaxRate.find_or_initialize_by(stripe_id: object.id)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stripe_model_callbacks-0.1.7 app/services/stripe_model_callbacks/tax_rate/updated_service.rb
stripe_model_callbacks-0.1.6 app/services/stripe_model_callbacks/tax_rate/updated_service.rb
stripe_model_callbacks-0.1.5 app/services/stripe_model_callbacks/tax_rate/updated_service.rb
stripe_model_callbacks-0.1.4 app/services/stripe_model_callbacks/tax_rate/updated_service.rb
stripe_model_callbacks-0.1.3 app/services/stripe_model_callbacks/tax_rate/updated_service.rb