Sha256: 0d15e3a5debca265d506c20a615e0ba41c3ee700ee43206eac3d565aeccb6a63

Contents?: true

Size: 352 Bytes

Versions: 7

Compression:

Stored size: 352 Bytes

Contents

class TrelloToken < ApplicationRecord
  class TokenAlreadyExist < RuntimeError; end

  before_create :confirm_singularity

  def self.instance
    first_or_create!
  end

  def filled?
    token.present? && secret.present?
  end

  private

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hubspot-api-client-9.0.0 sample-apps/trello-integration-app/app/models/trello_token.rb
hubspot-api-client-8.0.1 sample-apps/trello-integration-app/app/models/trello_token.rb
hubspot-api-client-8.0.0 sample-apps/trello-integration-app/app/models/trello_token.rb
hubspot-api-client-7.3.0 sample-apps/trello-integration-app/app/models/trello_token.rb
hubspot-api-client-7.2.0 sample-apps/trello-integration-app/app/models/trello_token.rb
hubspot-api-client-7.1.1 sample-apps/trello-integration-app/app/models/trello_token.rb
hubspot-api-client-7.1.0 sample-apps/trello-integration-app/app/models/trello_token.rb