Class: GraphitiGraphQL::Federation::FederatedResource
- Inherits:
-
Object
- Object
- GraphitiGraphQL::Federation::FederatedResource
- Defined in:
- lib/graphiti_graphql/federation/federated_resource.rb
Instance Attribute Summary collapse
-
#relationships ⇒ Object
readonly
Returns the value of attribute relationships.
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
Instance Method Summary collapse
- #add_relationship(kind, name, local_resource_class, foreign_key, &blk) ⇒ Object
-
#initialize(type_name) ⇒ FederatedResource
constructor
A new instance of FederatedResource.
- #klass_name ⇒ Object
- #polymorphic? ⇒ Boolean
Constructor Details
#initialize(type_name) ⇒ FederatedResource
Returns a new instance of FederatedResource.
6 7 8 9 |
# File 'lib/graphiti_graphql/federation/federated_resource.rb', line 6 def initialize(type_name) @type_name = type_name @relationships = {} end |
Instance Attribute Details
#relationships ⇒ Object (readonly)
Returns the value of attribute relationships.
4 5 6 |
# File 'lib/graphiti_graphql/federation/federated_resource.rb', line 4 def relationships @relationships end |
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
4 5 6 |
# File 'lib/graphiti_graphql/federation/federated_resource.rb', line 4 def type_name @type_name end |
Instance Method Details
#add_relationship(kind, name, local_resource_class, foreign_key, &blk) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/graphiti_graphql/federation/federated_resource.rb', line 11 def add_relationship( kind, name, local_resource_class, foreign_key, &blk ) @relationships[name] = FederatedRelationship .new(kind, name, local_resource_class, foreign_key) if blk @relationships[name].instance_eval(&blk) end end |
#klass_name ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/graphiti_graphql/federation/federated_resource.rb', line 29 def klass_name if polymorphic? "I#{@relationships.keys[0].to_s.camelize}" else @type_name end end |
#polymorphic? ⇒ Boolean
25 26 27 |
# File 'lib/graphiti_graphql/federation/federated_resource.rb', line 25 def polymorphic? @type_name.is_a?(Hash) end |