Module: ActionPolicy::GraphQL::Behaviour
- Defined in:
- lib/action_policy/graphql/behaviour.rb
Class Method Summary collapse
-
.extended(base) ⇒ Object
When used with self.authorized?.
- .included(base) ⇒ Object
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
When used with self.authorized?
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/action_policy/graphql/behaviour.rb', line 13 def self.extended(base) base.extend ActionPolicy::Behaviour base.extend ActionPolicy::Behaviours::ThreadMemoized base.extend ActionPolicy::Behaviours::Memoized base.extend ActionPolicy::Behaviours::Namespaced # Authorization context could't be defined for the class def base. {} end # Override authorization_namespace to use the class itself def base. return @authorization_namespace if instance_variable_defined?(:@authorization_namespace) @authorization_namespace = namespace end end |
.included(base) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/action_policy/graphql/behaviour.rb', line 31 def self.included(base) base.include ActionPolicy::Behaviour base.include ActionPolicy::Behaviours::ThreadMemoized base.include ActionPolicy::Behaviours::Memoized base.include ActionPolicy::Behaviours::Namespaced base. :user, through: :current_user if base.respond_to?(:field_class) unless base.field_class < ActionPolicy::GraphQL::AuthorizedField base.field_class.prepend(ActionPolicy::GraphQL::AuthorizedField) end unless base < ActionPolicy::GraphQL::Fields base.include ActionPolicy::GraphQL::Fields end end base.extend self end |
Instance Method Details
#current_user ⇒ Object
52 53 54 |
# File 'lib/action_policy/graphql/behaviour.rb', line 52 def current_user context[:current_user] end |