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.
7 8 9 |
# File 'lib/graphql/models/relation_load_request.rb', line 7 def initialize(relation) @relation = relation end |
Instance Attribute Details
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
5 6 7 |
# File 'lib/graphql/models/relation_load_request.rb', line 5 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.
25 26 27 |
# File 'lib/graphql/models/relation_load_request.rb', line 25 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
30 |
# File 'lib/graphql/models/relation_load_request.rb', line 30 def fulfilled(result); end |
#load ⇒ Object
32 33 34 |
# File 'lib/graphql/models/relation_load_request.rb', line 32 def load loader.load(self) end |
#load_target ⇒ Object
19 20 21 |
# File 'lib/graphql/models/relation_load_request.rb', line 19 def load_target relation end |
#load_type ⇒ Object
Public members that all load requests should implement
15 16 17 |
# File 'lib/graphql/models/relation_load_request.rb', line 15 def load_type :relation end |
#target_class ⇒ Object
Public members specific to a relation load request
40 41 42 |
# File 'lib/graphql/models/relation_load_request.rb', line 40 def target_class relation.klass end |