Sha256: af111ed0f933e9e5f459c218710bfe45770c7fdac8f8d90339a9c8c9bc597583

Contents?: true

Size: 928 Bytes

Versions: 23

Compression:

Stored size: 928 Bytes

Contents

require 'active_support/configurable'

module TypeStation
  # Configures global settings for TypeStation
  #   TypeStation.configure do |config|
  #     config.model = User
  #   end
  def self.configure(&block)
    yield @config ||= TypeStation::Configuration.new
  end

  # Global settings for TypeStation
  def self.config
    @config
  end

  class Configuration
    include ActiveSupport::Configurable

    config_accessor :authenticate_with
    config_accessor :authorise_with
    config_accessor :current_user

  end

  configure do |config|
    config.authenticate_with = Proc.new do
      request.env['warden'].try(:authenticate!)
    end
    
    config.authorise_with = Proc.new do
      request.env["warden"].try(:user) || respond_to?(:current_user) && current_user
    end

    config.current_user = Proc.new do
      request.env["warden"].try(:user) || respond_to?(:current_user) && current_user
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
type_station-0.7.0 lib/type_station/configuration.rb
type_station-0.6.0 lib/type_station/configuration.rb
type_station-0.5.4 lib/type_station/configuration.rb
type_station-0.5.3 lib/type_station/configuration.rb
type_station-0.5.2 lib/type_station/configuration.rb
type_station-0.5.1 lib/type_station/configuration.rb
type_station-0.4.7 lib/type_station/configuration.rb
type_station-0.4.6 lib/type_station/configuration.rb
type_station-0.4.5 lib/type_station/configuration.rb
type_station-0.4.4 lib/type_station/configuration.rb
type_station-0.4.3 lib/type_station/configuration.rb
type_station-0.4.2 lib/type_station/configuration.rb
type_station-0.4.1 lib/type_station/configuration.rb
type_station-0.4.0 lib/type_station/configuration.rb
type_station-0.3.4 lib/type_station/configuration.rb
type_station-0.3.3 lib/type_station/configuration.rb
type_station-0.3.2 lib/type_station/configuration.rb
type_station-0.3.1 lib/type_station/configuration.rb
type_station-0.3.0 lib/type_station/configuration.rb
type_station-0.2.3 lib/type_station/configuration.rb