Sha256: 303a33a5dc92a61951ca68e9f167df7894cd6cf82102b9e1d0ef86d1454a174a

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module FmRest
  module Spyke
    module Model
      module Auth
        extend ::ActiveSupport::Concern

        class_methods do
          # Logs out the database session for this model (and other models
          # using the same credentials).
          #
          # @raise [FmRest::V1::TokenSession::NoSessionTokenSet] if no session
          #   token was set (and no request is sent).
          def logout!
            connection.delete(FmRest::V1.session_path("dummy-token"))
          end

          # Logs out the database session for this model (and other models
          # using the same credentials). Unlike `logout!`, no exception is
          # raised in case of missing session token.
          #
          # @return [Boolean] Whether the logout request was sent (it's only
          #   sent if a session token was previously set)
          def logout
            logout!
            true
          rescue FmRest::V1::TokenSession::NoSessionTokenSet
            false
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fmrest-0.10.1 lib/fmrest/spyke/model/auth.rb
fmrest-0.10.0 lib/fmrest/spyke/model/auth.rb
fmrest-0.9.0 lib/fmrest/spyke/model/auth.rb
fmrest-0.8.0 lib/fmrest/spyke/model/auth.rb
fmrest-0.7.1 lib/fmrest/spyke/model/auth.rb
fmrest-0.7.0 lib/fmrest/spyke/model/auth.rb
fmrest-0.6.0 lib/fmrest/spyke/model/auth.rb