Module: GraphQL::Decorate::ObjectIntegration
- Defined in:
- lib/graphql/decorate/object_integration.rb
Overview
Extends GraphQL::Schema::Object classes with methods to set the desired decorator class and context.
Instance Attribute Summary collapse
-
#decorator_class ⇒ Class?
readonly
Gets the currently set decorator class.
-
#decorator_evaluator ⇒ Proc?
readonly
Gets the currently set decorator evaluator.
-
#decorator_metadata ⇒ Object
readonly
Returns the value of attribute decorator_metadata.
Class Method Summary collapse
Instance Method Summary collapse
-
#decorate_metadata {|object| ... } ⇒ Proc
Pass additional data to the decorator context (if supported).
-
#decorate_with(klass = nil, &block) ⇒ Object
Decorate the type with a decorator class.
Instance Attribute Details
#decorator_class ⇒ Class? (readonly)
Returns Gets the currently set decorator class.
29 30 31 |
# File 'lib/graphql/decorate/object_integration.rb', line 29 def decorator_class @decorator_class end |
#decorator_evaluator ⇒ Proc? (readonly)
Returns Gets the currently set decorator evaluator.
32 33 34 |
# File 'lib/graphql/decorate/object_integration.rb', line 32 def decorator_evaluator @decorator_evaluator end |
#decorator_metadata ⇒ Object (readonly)
Returns the value of attribute decorator_metadata.
34 35 36 |
# File 'lib/graphql/decorate/object_integration.rb', line 34 def @decorator_metadata end |
Class Method Details
.included(base) ⇒ nil
9 10 11 |
# File 'lib/graphql/decorate/object_integration.rb', line 9 def self.included(base) base.extend(self) end |
Instance Method Details
#decorate_metadata {|object| ... } ⇒ Proc
Pass additional data to the decorator context (if supported).
23 24 25 26 |
# File 'lib/graphql/decorate/object_integration.rb', line 23 def @decorator_metadata ||= GraphQL::Decorate::Metadata.new yield(@decorator_metadata) end |
#decorate_with(klass = nil, &block) ⇒ Object
Decorate the type with a decorator class.
15 16 17 18 |
# File 'lib/graphql/decorate/object_integration.rb', line 15 def decorate_with(klass = nil, &block) @decorator_class = klass @decorator_evaluator = block end |