Sha256: d32d71d80d2f31dd0f8cb0c448023b2f6c439f74ada1df8f4bd995b1dc9aa763

Contents?: true

Size: 1.12 KB

Versions: 17

Compression:

Stored size: 1.12 KB

Contents

module Sorcery
  module Providers
    class Base
      attr_reader   :access_token

      attr_accessor :callback_url, :key, :original_callback_url, :secret,
                    :site, :state, :user_info_mapping

      def has_callback?
        true
      end

      def initialize
        @user_info_mapping = {}
      end

      def auth_hash(access_token, hash = {})
        return hash if access_token.nil?

        token_hash = hash.dup
        token_hash[:token] = access_token.token if access_token.respond_to?(:token)
        token_hash[:refresh_token] = access_token.refresh_token if access_token.respond_to?(:refresh_token)
        token_hash[:expires_at] = access_token.expires_at if access_token.respond_to?(:expires_at)
        token_hash[:expires_in] = access_token.expires_at if access_token.respond_to?(:expires_in)
        token_hash
      end

      def self.name
        super.gsub(/Sorcery::Providers::/, '').downcase
      end

      # Ensure that all descendant classes are loaded before run this
      def self.descendants
        ObjectSpace.each_object(Class).select { |klass| klass < self }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sorcery-0.17.0 lib/sorcery/providers/base.rb
sorcery-0.16.5 lib/sorcery/providers/base.rb
sorcery-0.16.4 lib/sorcery/providers/base.rb
sorcery-0.16.3 lib/sorcery/providers/base.rb
sorcery-0.16.2 lib/sorcery/providers/base.rb
sorcery-0.16.1 lib/sorcery/providers/base.rb
sorcery-0.15.1 lib/sorcery/providers/base.rb
sorcery-0.16.0 lib/sorcery/providers/base.rb
sorcery-0.15.0 lib/sorcery/providers/base.rb
sorcery-0.14.0 lib/sorcery/providers/base.rb
sorcery-0.13.0 lib/sorcery/providers/base.rb
sorcery-0.12.0 lib/sorcery/providers/base.rb
sorcery-0.11.0 lib/sorcery/providers/base.rb
sorcery-0.10.3 lib/sorcery/providers/base.rb
sorcery-0.10.2 lib/sorcery/providers/base.rb
sorcery-0.10.1 lib/sorcery/providers/base.rb
sorcery-0.10.0 lib/sorcery/providers/base.rb