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, query = nil, 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.
14 15 16 |
# File 'lib/graphql-pundit.rb', line 14 def initialize() @raise_unauthorized = end |
Instance Attribute Details
#raise_unauthorized ⇒ Object (readonly)
Returns the value of attribute raise_unauthorized.
12 13 14 |
# File 'lib/graphql-pundit.rb', line 12 def @raise_unauthorized end |
Instance Method Details
#call(defn, query = nil, policy: nil, record: nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/graphql-pundit.rb', line 18 def call(defn, query = nil, policy: nil, record: nil) opts = {record: record, query: query || defn.name, policy: policy, raise: } if query.respond_to?(:call) opts = {proc: query, raise: } end Define::InstanceDefinable::AssignMetadataKey.new(:authorize). call(defn, opts) end |