Sha256: 23b53c2d94b352ca169a6f1e7439c8c233de05dfaf76607bc614515e494f5ad0

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

module Clearance
  class Configuration
    attr_writer :allow_sign_up

    attr_accessor \
      :cookie_domain,
      :cookie_expiration,
      :cookie_path,
      :httponly,
      :mailer_sender,
      :password_strategy,
      :redirect_url,
      :secure_cookie,
      :sign_in_guards,
      :user_model

    def initialize
      @allow_sign_up = true
      @cookie_expiration = ->(cookies) { 1.year.from_now.utc }
      @cookie_path = '/'
      @httponly = false
      @mailer_sender = 'reply@example.com'
      @redirect_url = '/'
      @secure_cookie = false
      @sign_in_guards = []
    end

    def user_model
      @user_model || ::User
    end

    def allow_sign_up?
      @allow_sign_up
    end

    def  user_actions
      if allow_sign_up?
        [:create]
      else
        []
      end
    end

    def user_id_parameter
      "#{user_model.model_name.singular}_id".to_sym
    end
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configuration=(config)
    @configuration = config
  end

  def self.configure
    yield configuration
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clearance-1.4.3 lib/clearance/configuration.rb
clearance-1.4.2 lib/clearance/configuration.rb
clearance-1.4.1 lib/clearance/configuration.rb
clearance-1.4.0 lib/clearance/configuration.rb
clearance-1.3.0 lib/clearance/configuration.rb
clearance-1.2.1 lib/clearance/configuration.rb
clearance-1.2.0 lib/clearance/configuration.rb