Sha256: 488816b4c4cfac605908c19fde4071c5259d7774d66cbf1d3429af2300d171ce

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

module SimpleTokenAuthentication
  module Configuration

    mattr_reader   :fallback
    mattr_accessor :header_names
    mattr_accessor :sign_in_token
    mattr_accessor :controller_adapters
    mattr_accessor :model_adapters
    mattr_accessor :adapters_dependencies

    # Default configuration
    @@fallback = :devise
    @@header_names = {}
    @@sign_in_token = false
    @@controller_adapters = ['rails', 'rails_api']
    @@model_adapters = ['active_record', 'mongoid']
    @@adapters_dependencies = { 'active_record' => 'ActiveRecord::Base',
                                'mongoid'       => 'Mongoid::Document',
                                'rails'         => 'ActionController::Base',
                                'rails_api'     => 'ActionController::API' }

    # Allow the default configuration to be overwritten from initializers
    def configure
      yield self if block_given?
    end

    def parse_options(options)
      unless options[:fallback].presence
        if options[:fallback_to_devise]
          options[:fallback] = :devise
        elsif options[:fallback_to_devise] == false
          if SimpleTokenAuthentication.fallback == :devise
              options[:fallback] = :none
          else
            options[:fallback] = SimpleTokenAuthentication.fallback
          end
        else
          options[:fallback] = SimpleTokenAuthentication.fallback
        end
      end
      options.reject! { |k,v| k == :fallback_to_devise }
      options
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
stn-simple_token_authentication-1.7.1 lib/simple_token_authentication/configuration.rb
simple_token_authentication-1.7.0 lib/simple_token_authentication/configuration.rb