Class: BetterAuthy::ScopeConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/better_authy/scope_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ScopeConfiguration

Returns a new instance of ScopeConfiguration.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/better_authy/scope_configuration.rb', line 10

def initialize(name)
  @name = name.to_sym
  @session_key = :"#{name}_id"
  @remember_cookie = :"_remember_#{name}_token"
  @remember_for = 2.weeks
  @password_reset_within = 1.hour
  @sign_in_path = "/auth/#{name}/login"
  @after_sign_in_path = "/"
  @layout = "better_authy/application"
  @enable_sign_up = true
end

Instance Attribute Details

#after_sign_in_path ⇒ Object

Returns the value of attribute after_sign_in_path.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def 
  @after_sign_in_path
end

#enable_sign_up ⇒ Object

Returns the value of attribute enable_sign_up.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def 
  @enable_sign_up
end

#layout ⇒ Object

Returns the value of attribute layout.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def layout
  @layout
end

#model_name ⇒ Object

Returns the value of attribute model_name.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def model_name
  @model_name
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/better_authy/scope_configuration.rb', line 5

def name
  @name
end

#password_reset_within ⇒ Object

Returns the value of attribute password_reset_within.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def password_reset_within
  @password_reset_within
end

Returns the value of attribute remember_cookie.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def remember_cookie
  @remember_cookie
end

#remember_for ⇒ Object

Returns the value of attribute remember_for.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def remember_for
  @remember_for
end

#session_key ⇒ Object

Returns the value of attribute session_key.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def session_key
  @session_key
end

#sign_in_path ⇒ Object

Returns the value of attribute sign_in_path.



6
7
8
# File 'lib/better_authy/scope_configuration.rb', line 6

def 
  @sign_in_path
end

Instance Method Details

#model_class ⇒ Object

Raises:



26
27
28
29
30
# File 'lib/better_authy/scope_configuration.rb', line 26

def model_class
  raise ConfigurationError, "model_name is required for scope :#{name}" if model_name.blank?

  model_name.constantize
end

#sign_up_enabled? ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/better_authy/scope_configuration.rb', line 22

def 
  @enable_sign_up
end

#validate! ⇒ Object

Raises:



32
33
34
# File 'lib/better_authy/scope_configuration.rb', line 32

def validate!
  raise ConfigurationError, "model_name is required for scope :#{name}" if model_name.blank?
end