Class: Godmin::Resolver

Inherits:
ActionView::FileSystemResolver
  • Object
show all
Defined in:
lib/godmin/resolver.rb

Direct Known Subclasses

EngineResolver, GodminResolver

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, controller_path, engine_wrapper) ⇒ Resolver

Returns a new instance of Resolver.



13
14
15
16
17
# File 'lib/godmin/resolver.rb', line 13

def initialize(path, controller_path, engine_wrapper)
  super(path)
  @controller_path = controller_path
  @engine_wrapper = engine_wrapper
end

Class Method Details

.resolvers(controller_path, engine_wrapper) ⇒ Object



6
7
8
9
10
11
# File 'lib/godmin/resolver.rb', line 6

def self.resolvers(controller_path, engine_wrapper)
  [
    EngineResolver.new(controller_path, engine_wrapper),
    GodminResolver.new(controller_path, engine_wrapper)
  ]
end

Instance Method Details

#_find_all(name, prefix, partial, details, key, locals) ⇒ Object

This function is for Rails 6 and up since the ‘find_templates` function is deprecated. It does the same thing, just a little differently. It’s not being run by versions previous to Rails 6.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/godmin/resolver.rb', line 22

def _find_all(name, prefix, partial, details, key, locals)
  templates = []

  template_paths(prefix).each do |p|
    break if templates.present?

    path = Path.build(name, "#{@path}/#{p}", partial)
    templates = query(path, details, details[:formats], locals, cache: !!key)
  end

  templates
end

#find_templates(name, prefix, *args) ⇒ Object

This is how we find templates in Rails 5 and below.



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/godmin/resolver.rb', line 36

def find_templates(name, prefix, *args)
  templates = []

  template_paths(prefix).each do |path|
    break if templates.present?

    templates = super(name, path, *args)
  end

  templates
end