Class: GraphQL::AuthorizationHelper
- Inherits:
-
Object
- Object
- GraphQL::AuthorizationHelper
- Defined in:
- lib/graphql-pundit.rb
Overview
Defines ‘authorize` and `authorize!` helpers
Instance Attribute Summary collapse
-
#raise_unauthorized ⇒ Object
readonly
Returns the value of attribute raise_unauthorized.
Instance Method Summary collapse
- #call(defn, *args, policy: nil, record: nil) ⇒ Object
-
#initialize(raise_unauthorized) ⇒ AuthorizationHelper
constructor
A new instance of AuthorizationHelper.
Constructor Details
#initialize(raise_unauthorized) ⇒ AuthorizationHelper
Returns a new instance of AuthorizationHelper.
17 18 19 |
# File 'lib/graphql-pundit.rb', line 17 def initialize() @raise_unauthorized = end |
Instance Attribute Details
#raise_unauthorized ⇒ Object (readonly)
Returns the value of attribute raise_unauthorized.
15 16 17 |
# File 'lib/graphql-pundit.rb', line 15 def @raise_unauthorized end |
Instance Method Details
#call(defn, *args, policy: nil, record: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/graphql-pundit.rb', line 21 def call(defn, *args, policy: nil, record: nil) query = args[0] || defn.name opts = {record: record, query: query, policy: policy, raise: } if query.respond_to?(:call) opts = {proc: query, raise: } end Define::InstanceDefinable::AssignMetadataKey.new(:authorize). call(defn, opts) end |