Class: GraphqlAuthorize::AuthAdapters::CanCanCan

Inherits:
Base
  • Object
show all
Defined in:
lib/graphql_authorize/auth_adapters/can_can_can.rb

Instance Attribute Summary

Attributes inherited from Base

#context, #field_definition

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GraphqlAuthorize::AuthAdapters::Base

Instance Method Details

#authorizeObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/graphql_authorize/auth_adapters/can_can_can.rb', line 6

def authorize
  unless field_definition.authorize.is_a?(Array)
    raise ArgumentError, I18n.t("graphql_authorize.auth.arrayargs")
  end

  unless source.respond_to?(:can?)
    raise ArgumentError, I18n.t("graphql_authorize.auth.canrespond")
  end

  source.can?(*field_definition.authorize)
end