Class: GraphQL::AssociationBatchResolver::ResolverBuilder
- Inherits:
-
Object
- Object
- GraphQL::AssociationBatchResolver::ResolverBuilder
- Defined in:
- lib/graphql/association_batch_resolver/resolver_builder.rb
Instance Attribute Summary collapse
-
#association ⇒ Object
Returns the value of attribute association.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
- #association_class_name ⇒ Object
- #define_resolver ⇒ Object
-
#initialize(model, association) ⇒ ResolverBuilder
constructor
A new instance of ResolverBuilder.
- #resolver ⇒ Object
- #resolver_class_name ⇒ Object
Constructor Details
#initialize(model, association) ⇒ ResolverBuilder
Returns a new instance of ResolverBuilder.
11 12 13 14 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 11 def initialize(model, association) @model = model @association = association end |
Instance Attribute Details
#association ⇒ Object
Returns the value of attribute association.
9 10 11 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 9 def association @association end |
#model ⇒ Object
Returns the value of attribute model.
9 10 11 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 9 def model @model end |
Instance Method Details
#association_class_name ⇒ Object
20 21 22 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 20 def association_class_name association.to_s.classify end |
#define_resolver ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 30 def define_resolver resolver = Class.new(AssociationResolver) resolver.model = model resolver.association = association model.const_set(resolver_class_name, resolver) resolver.validate! end |
#resolver ⇒ Object
24 25 26 27 28 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 24 def resolver define_resolver unless model.const_defined?(resolver_class_name) model.const_get(resolver_class_name) end |
#resolver_class_name ⇒ Object
16 17 18 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 16 def resolver_class_name @resolver_class_name ||= "#{association_class_name}Resolver" end |