Class: AutoPreload::Resolver
- Inherits:
-
Object
- Object
- AutoPreload::Resolver
- Defined in:
- lib/auto_preload/resolver.rb
Overview
This class parses a string in the format “articles,comments” and returns an array of symbols.
Constant Summary collapse
- MAX_ITERATIONS =
Default max number of iterations
100
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Resolver
constructor
A new instance of Resolver.
-
#resolve(query, inclusions) ⇒ Array<Symbol, Hash>
Resolves a string as an array of symbols or hashes.
Constructor Details
#initialize(options = {}) ⇒ Resolver
Returns a new instance of Resolver.
13 14 15 16 17 18 |
# File 'lib/auto_preload/resolver.rb', line 13 def initialize( = {}) @iterations = 0 @options = @max_iterations = [:max_iterations] || MAX_ITERATIONS @adapter = AutoPreload.config.adapter end |
Instance Method Details
#resolve(query, inclusions) ⇒ Array<Symbol, Hash>
Resolves a string as an array of symbols or hashes.
25 26 27 28 29 |
# File 'lib/auto_preload/resolver.rb', line 25 def resolve(query, inclusions) model = query.respond_to?(:klass) ? query.klass : query format_output(run_resolve(model, inclusions, root: true)) end |