Class: Wallaby::Configuration::Security
- Inherits:
-
Object
- Object
- Wallaby::Configuration::Security
- Defined in:
- lib/wallaby/configuration/security.rb
Constant Summary collapse
- DEFAULT_CURRENT_USER =
by default, current_user returns nil
-> {}
- DEFAULT_AUTHENTICATE =
by default, authenticate returns true not to stop the before_action chain
-> { true }
Instance Method Summary collapse
- #authenticate(&block) ⇒ Object
- #authenticate? ⇒ Boolean
- #current_user(&block) ⇒ Object
- #current_user? ⇒ Boolean
Instance Method Details
#authenticate(&block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/wallaby/configuration/security.rb', line 19 def authenticate(&block) if block_given? @authenticate = block else @authenticate ||= DEFAULT_AUTHENTICATE end end |
#authenticate? ⇒ Boolean
27 28 29 |
# File 'lib/wallaby/configuration/security.rb', line 27 def authenticate? authenticate != DEFAULT_AUTHENTICATE end |
#current_user(&block) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/wallaby/configuration/security.rb', line 7 def current_user(&block) if block_given? @current_user = block else @current_user ||= DEFAULT_CURRENT_USER end end |
#current_user? ⇒ Boolean
15 16 17 |
# File 'lib/wallaby/configuration/security.rb', line 15 def current_user? current_user != DEFAULT_CURRENT_USER end |