lib/authorizable/controller.rb
# check if the resource can perform the action and respond
# according to the specefied config
#
# @param [Symbol] action the current controller action
# @param [Hash] config the configuration for what to do with the given action
# @return [Boolean] the result of the permission evaluation
check if the resource can perform the action and respond
according to the specefied config
check if the resource can perform the action and respond according to the specefied config
def is_authorized_for_action_with_config?(action, config)
      request_may_proceed = false
      return true unless config.present?
      defaults = {
        user: current_user,
        permission: action.to_s,
        message: I18n.t('authorizable.not_authorized'),
        flash_type: Authorizable.configuration.flash_error
      }
      options = defaults.merge(config)
      request_may_proceed = evaluate_action_permission(options)
      unless request_may_proceed and request.format == :html
        authorizable_respond_with(
          options[:flash_type],
          options[:message],
          options[:redirect_path]
        )
        return false
      end
      true
    end
def is_authorized_for_action_with_config? ( action , config ) request_may_proceed = false return true unless config . present? defaults = { user : current_user , permission : action . to_s , message : I18n . t ( 'authorizable.not_authorized' ) , flash_type : Authorizable . configuration . flash_error } options = defaults . merge ( config ) request_may_proceed = evaluate_action_permission ( options ) unless request_may_proceed and request . format == :html authorizable_respond_with ( options [ :flash_type ] , options [ :message ] , options [ :redirect_path ] ) return false end true end
check if the resource can perform the action and respond
according to the specefied config
check if the resource can perform the action and respond according to the specefied config
# run permission # redirect # halt # proceed with request execution
the result of the permission evaluation
the result of the permission evaluation
Boolean
action
config
config the configuration for what to do with the given action
config the configuration for what to do with the given action