Class: GraphQL::Models::RelationLoadRequest
- Inherits:
-
Object
- Object
- GraphQL::Models::RelationLoadRequest
- Defined in:
- lib/graphql/models/relation_load_request.rb
Instance Attribute Summary collapse
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Instance Method Summary collapse
-
#ensure_cardinality(result) ⇒ Object
If the value should be an array, make sure it’s an array.
-
#fulfilled(result) ⇒ Object
When the request is fulfilled, this method is called so that it can do whatever caching, etc.
-
#initialize(relation) ⇒ RelationLoadRequest
constructor
A new instance of RelationLoadRequest.
- #load ⇒ Object
- #load_target ⇒ Object
-
#load_type ⇒ Object
Public members that all load requests should implement.
-
#target_class ⇒ Object
Public members specific to a relation load request.
Constructor Details
#initialize(relation) ⇒ RelationLoadRequest
Returns a new instance of RelationLoadRequest.
8 9 10 |
# File 'lib/graphql/models/relation_load_request.rb', line 8 def initialize(relation) @relation = relation end |
Instance Attribute Details
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
6 7 8 |
# File 'lib/graphql/models/relation_load_request.rb', line 6 def relation @relation end |
Instance Method Details
#ensure_cardinality(result) ⇒ Object
If the value should be an array, make sure it’s an array. If it should be a single value, make sure it’s single. Passed in result could be a single model or an array of models.
26 27 28 |
# File 'lib/graphql/models/relation_load_request.rb', line 26 def ensure_cardinality(result) Array.wrap(result) end |
#fulfilled(result) ⇒ Object
When the request is fulfilled, this method is called so that it can do whatever caching, etc. is needed
31 |
# File 'lib/graphql/models/relation_load_request.rb', line 31 def fulfilled(result); end |
#load ⇒ Object
33 34 35 |
# File 'lib/graphql/models/relation_load_request.rb', line 33 def load loader.load(self) end |
#load_target ⇒ Object
20 21 22 |
# File 'lib/graphql/models/relation_load_request.rb', line 20 def load_target relation end |
#load_type ⇒ Object
Public members that all load requests should implement
16 17 18 |
# File 'lib/graphql/models/relation_load_request.rb', line 16 def load_type :relation end |
#target_class ⇒ Object
Public members specific to a relation load request
41 42 43 |
# File 'lib/graphql/models/relation_load_request.rb', line 41 def target_class relation.klass end |