Class: Godmin::Resolver

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

Instance Method Summary collapse

Constructor Details

#initialize(controller_path, engine_wrapper) ⇒ Resolver

Returns a new instance of Resolver.



3
4
5
6
7
# File 'lib/godmin/resolver.rb', line 3

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

Instance Method Details

#find_templates(name, prefix, partial, details) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/godmin/resolver.rb', line 9

def find_templates(name, prefix, partial, details)
  templates = []

  template_paths(prefix).each do |path|
    if templates.present?
      break
    else
      templates = super(name, path, partial, details)
    end
  end

  templates
end

#template_paths(prefix) ⇒ Object

Matches templates such as:

{ name: index, prefix: articles } => [app/views/resource/index, godmin/app/views/godmin/resource/index] { name: form, prefix: articles } => [app/views/resource/_form, godmin/app/views/godmin/resource/_form] { name: title, prefix: columns } => [app/views/resource/columns/_title] { name: welcome, prefix: application } => [godmin/app/views/godmin/application/welcome] { name: navigation, prefix: shared } => [godmin/app/views/godmin/shared/navigation]



30
31
32
33
34
35
36
# File 'lib/godmin/resolver.rb', line 30

def template_paths(prefix)
  [
    File.join(@engine_wrapper.root, "app/views", resource_path_for_engine(prefix)),
    File.join(Godmin::Engine.root, "app/views/godmin", default_path_for_godmin(prefix)),
    File.join(Godmin::Engine.root, "app/views/godmin", resource_path_for_godmin(prefix))
  ]
end