Class: ActionController::Metal

Inherits:
Object
  • Object
show all
Defined in:
lib/authorizer/action_controller_patch.rb

Instance Method Summary collapse

Instance Method Details

#check_authorization(resource, authorizee, **options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/authorizer/action_controller_patch.rb', line 7

def check_authorization(resource, authorizee, **options)
    action = "#{params[:controller]}##{action_name}"

    if resource.respond_to?(:length)
        return resource if resource.length == 0
        r = Resource.new(action, authorizee, *resource, **options)
        result = r.get
    else
        result = resource.is_authorized(action, authorizee)
    end

    result
end