Class: GraphQL::Decorate::Decoration
- Inherits:
-
Object
- Object
- GraphQL::Decorate::Decoration
- Defined in:
- lib/graphql/decorate/decoration.rb
Overview
Handles decorating an value at runtime given its current field.
Class Method Summary collapse
-
.decorate(undecorated_field) ⇒ Object
Resolve the undecorated_field.value with decoration.
Instance Method Summary collapse
-
#decorate ⇒ Object
Decorated undecorated_field.value if possible, otherwise the original undecorated_field.value.
-
#initialize(undecorated_field) ⇒ Decoration
constructor
A new instance of Decoration.
Constructor Details
#initialize(undecorated_field) ⇒ Decoration
Returns a new instance of Decoration.
15 16 17 |
# File 'lib/graphql/decorate/decoration.rb', line 15 def initialize(undecorated_field) @undecorated_field = undecorated_field end |
Class Method Details
.decorate(undecorated_field) ⇒ Object
Resolve the undecorated_field.value with decoration.
10 11 12 |
# File 'lib/graphql/decorate/decoration.rb', line 10 def self.decorate(undecorated_field) new(undecorated_field).decorate end |
Instance Method Details
#decorate ⇒ Object
Returns Decorated undecorated_field.value if possible, otherwise the original undecorated_field.value.
20 21 22 23 24 25 26 27 |
# File 'lib/graphql/decorate/decoration.rb', line 20 def decorate if undecorated_field.decorator_class GraphQL::Decorate.configuration.evaluate_decorator.call(undecorated_field.decorator_class, undecorated_field.value, undecorated_field.) else undecorated_field.value end end |