Sha256: 9d6867423b3379970314bb312545482881c4980a665ac9dd8208ed20c21e131c

Contents?: true

Size: 281 Bytes

Versions: 22

Compression:

Stored size: 281 Bytes

Contents

class Token < ApplicationRecord
  class TokenAlreadyExist < RuntimeError; end

  before_create :confirm_singularity

  def self.instance
    first_or_create!
  end

  private

  def confirm_singularity
    raise(TokenAlreadyExist, 'There can be only one.') if Token.any?
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hubspot-api-client-2.0.0 sample-apps/webhooks-contacts-app/app/models/token.rb
hubspot-api-client-1.0.1 sample-apps/webhooks-contacts-app/app/models/token.rb