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.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #association_class_name ⇒ Object
- #define_resolver ⇒ Object
-
#initialize(model, association, opts) ⇒ ResolverBuilder
constructor
A new instance of ResolverBuilder.
- #resolver ⇒ Object
- #resolver_class_name ⇒ Object
Constructor Details
#initialize(model, association, opts) ⇒ ResolverBuilder
Returns a new instance of ResolverBuilder.
11 12 13 14 15 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 11 def initialize(model, association, opts) @model = model @association = association @options = opts 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 |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 9 def @options end |
Instance Method Details
#association_class_name ⇒ Object
21 22 23 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 21 def association_class_name association.to_s.classify end |
#define_resolver ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 31 def define_resolver resolver = Class.new(AssociationResolver) resolver.model = model resolver.association = association resolver. = model.const_set(resolver_class_name, resolver) resolver.validate! end |
#resolver ⇒ Object
25 26 27 28 29 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 25 def resolver define_resolver unless model.const_defined?(resolver_class_name) model.const_get(resolver_class_name) end |
#resolver_class_name ⇒ Object
17 18 19 |
# File 'lib/graphql/association_batch_resolver/resolver_builder.rb', line 17 def resolver_class_name @resolver_class_name ||= "#{association_class_name}Resolver" end |