Class: Panoramic::Resolver
- Inherits:
-
ActionView::Resolver
- Object
- ActionView::Resolver
- Panoramic::Resolver
- Includes:
- Singleton
- Defined in:
- lib/panoramic/resolver.rb
Class Method Summary collapse
-
.using(model, options = {}) ⇒ Object
Instantiate Resolver by passing a model (decoupled from ORMs).
Instance Method Summary collapse
-
#find_templates(name, prefix, partial, details, key = nil, locals = []) ⇒ Object
this method is mandatory to implement a Resolver.
Class Method Details
.using(model, options = {}) ⇒ Object
Instantiate Resolver by passing a model (decoupled from ORMs)
24 25 26 27 28 |
# File 'lib/panoramic/resolver.rb', line 24 def self.using(model, ={}) @@model = model @@resolver_options = self.instance end |
Instance Method Details
#find_templates(name, prefix, partial, details, key = nil, locals = []) ⇒ Object
this method is mandatory to implement a Resolver
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/panoramic/resolver.rb', line 7 def find_templates(name, prefix, partial, details, key=nil, locals=[]) return [] if @@resolver_options[:only] && !@@resolver_options[:only].include?(prefix) conditions = { :path => build_path(name, prefix), :locale => [normalize_array(details[:locale]).first, nil], :format => normalize_array(details[:formats]), :handler => normalize_array(details[:handlers]), :partial => partial || false }.merge(details[:additional_criteria].presence || {}) @@model.find_model_templates(conditions).map do |record| initialize_template(record) end end |