Class: Auth::Behavior::Base::Configuration

Inherits:
Object
  • Object
show all
Includes:
Configuration::Keys
Defined in:
lib/auth/behavior/base/configuration.rb

Direct Known Subclasses

RememberMe::Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Configuration::Keys

#configuration_keys, included, #to_hash

Constructor Details

#initialize(configuration) ⇒ Configuration

Returns a new instance of Configuration.



27
28
29
30
# File 'lib/auth/behavior/base/configuration.rb', line 27

def initialize(configuration)
  @configuration = configuration
  defaults!
end

Instance Attribute Details

#configurationObject (readonly)

Provides a handle back to the root configuration object.



3
4
5
# File 'lib/auth/behavior/base/configuration.rb', line 3

def configuration
  @configuration
end

Class Method Details

.configuration_name(new_name = nil) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/auth/behavior/base/configuration.rb', line 8

def configuration_name(new_name = nil)
  if new_name
    @configuration_name = new_name.to_sym
  else
    # the sub removes Configuration, ie Auth::Behavior::Core::Configuration becomes Auth::Behavior::Core
    @configuration_name = name.sub(/\:\:[^\:]*$/, '').demodulize.underscore.to_sym
  end
end

Instance Method Details

#configuration_nameObject



23
24
25
# File 'lib/auth/behavior/base/configuration.rb', line 23

def configuration_name
  self.class.configuration_name
end

#defaults!Object Also known as: reset!



32
33
34
# File 'lib/auth/behavior/base/configuration.rb', line 32

def defaults!
  raise "Don't forget to override #{self.class.name}#defaults!"
end

#enabled?Boolean

Returns true if the root configuration object’s behaviors include :remember_me.

Returns:

  • (Boolean)


19
20
21
# File 'lib/auth/behavior/base/configuration.rb', line 19

def enabled?
  configuration.behaviors.include? configuration_name
end