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.
6 7 8 |
# File 'lib/graphql/models/relation_load_request.rb', line 6 def initialize(relation) @relation = relation end |
Instance Attribute Details
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
4 5 6 |
# File 'lib/graphql/models/relation_load_request.rb', line 4 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.
24 25 26 |
# File 'lib/graphql/models/relation_load_request.rb', line 24 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
29 30 |
# File 'lib/graphql/models/relation_load_request.rb', line 29 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
18 19 20 |
# File 'lib/graphql/models/relation_load_request.rb', line 18 def load_target relation end |
#load_type ⇒ Object
Public members that all load requests should implement
14 15 16 |
# File 'lib/graphql/models/relation_load_request.rb', line 14 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 |