Module: Masks::Controller::ClassMethods
- Defined in:
- app/controllers/concerns/masks/controller.rb
Instance Method Summary collapse
-
#require_access(name, **opts) ⇒ Object
Builds an access object by the passed name, if allowed.
-
#require_mask(type: nil, **opts) ⇒ Object
Require a session masked by the type passed.
Instance Method Details
#require_access(name, **opts) ⇒ Object
Builds an access object by the passed name, if allowed.
If this succeeds, the controller instance’s current_access
will return the constructed access class. Otherwise, on failure the unathorized_access
method is called.
48 49 50 51 52 53 54 |
# File 'app/controllers/concerns/masks/controller.rb', line 48 def require_access(name, **opts) before_action( :unauthorized_access, unless: -> { build_access(name) }, **opts ) end |
#require_mask(type: nil, **opts) ⇒ Object
Require a session masked by the type passed.
If this fails unathorized_access
is called.
17 18 19 20 21 22 23 |
# File 'app/controllers/concerns/masks/controller.rb', line 17 def require_mask(type: nil, **opts) before_action( :unauthorized_access, unless: -> { masked?(type:) }, **opts ) end |