Class: Entrance::Config
- Inherits:
-
Object
- Object
- Entrance::Config
- Defined in:
- lib/entrance/config.rb
Instance Method Summary collapse
- #can?(what, val = nil) ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #permit!(option) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/entrance/config.rb', line 12 def initialize @model = 'User' @local_auth = true @remote_auth = false # strategies @cipher = Entrance::Ciphers::BCrypt # or Entrance::Ciphers::SHA1 @secret = nil @stretches = 10 # access denied @access_denied_redirect_to = '/login' @access_denied_message_key = nil # e.g. 'messages.access_denied' # reset password @reset_password_mailer = 'UserMailer' @reset_password_method = 'reset_password_request' @reset_password_window = 60 * 60 # 1.hour # remember me & cookies @remember_for = 60 * 24 * 14 # 2.weeks @cookie_domain = nil @cookie_secure = true @cookie_path = '/' @cookie_httponly = false end |
Instance Method Details
#can?(what, val = nil) ⇒ Boolean
45 46 47 48 49 50 51 |
# File 'lib/entrance/config.rb', line 45 def can?(what, val = nil) if val instance_variable_set("@can_#{what}", val) else !!instance_variable_get("@can_#{what}") end end |
#permit!(option) ⇒ Object
53 54 55 |
# File 'lib/entrance/config.rb', line 53 def permit!(option) raise "#{option} is disabled!" unless can?(option) end |