class Wallaby::ModelAuthorizationProvider
Model Authorizer interface. @since wallaby-5.2.0
Attributes
@!attribute [w] provider_name
@!attribute [r] context @return [ActionController::Base, ActionView::Base]
@!attribute [r] options @return [Hash]
@!attribute [r] user @return [Object]
Public Class Methods
@note Template method to check and see if current provider is in used. @param _context [ActionController::Base, ActionView::Base] @raise [Wallaby::NotImplemented]
# File lib/interfaces/wallaby/model_authorization_provider.rb, line 22 def available?(_context) raise NotImplemented end
@param context [ActionController::Base, ActionView::Base] @param options [Hash]
# File lib/interfaces/wallaby/model_authorization_provider.rb, line 41 def initialize(context, **options) @context = context @options = options @user = context.try :wallaby_user end
@!attribute [r] provider_name
This is the provider name that can be set in Wallaby::ModelAuthorizer
subclasses. @see Wallaby::ModelAuthorizer.provider_name
@return [String/Symbol] provider name
# File lib/interfaces/wallaby/model_authorization_provider.rb, line 15 def provider_name @provider_name ||= name.demodulize.gsub(/(Authorization)?Provider/, EMPTY_STRING).underscore end
Public Instance Methods
@note It can be overridden in subclasses for customization purpose. This is the template method to restrict user's access to certain scope. @param _action [Symbol, String] @param _scope [Object] @raise [Wallaby::NotImplemented]
# File lib/interfaces/wallaby/model_authorization_provider.rb, line 79 def accessible_for(_action, _scope) raise NotImplemented end
@note It can be overridden in subclasses for customization purpose. This is the template method to restrict user's modification to certain fields of given subject. @param _action [Symbol, String] @param _subject [Object] @raise [Wallaby::NotImplemented]
# File lib/interfaces/wallaby/model_authorization_provider.rb, line 88 def attributes_for(_action, _subject) raise NotImplemented end
@note It can be overridden in subclasses for customization purpose. This is the template method to restrict user's mass assignment to certain fields of given subject. @param _action [Symbol, String] @param _subject [Object] @raise [Wallaby::NotImplemented]
# File lib/interfaces/wallaby/model_authorization_provider.rb, line 97 def permit_params(_action, _subject) raise NotImplemented end