Class: Godmin::GodminResolver

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

Overview

Matches templates such as:

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

Instance Method Summary collapse

Methods inherited from Resolver

#_find_all, #find_templates, resolvers

Constructor Details

#initialize(controller_path, engine_wrapper) ⇒ GodminResolver

Returns a new instance of GodminResolver.



77
78
79
# File 'lib/godmin/resolver.rb', line 77

def initialize(controller_path, engine_wrapper)
  super(File.join(Godmin::Engine.root, "app/views/godmin"), controller_path, engine_wrapper)
end

Instance Method Details

#default_path_for_godmin(prefix) ⇒ Object



88
89
90
# File 'lib/godmin/resolver.rb', line 88

def default_path_for_godmin(prefix)
  prefix.sub(/\A#{File.join(@engine_wrapper.namespaced_path)}/, "").sub(/\A\//, "")
end

#resource_path_for_godmin(prefix) ⇒ Object



92
93
94
# File 'lib/godmin/resolver.rb', line 92

def resource_path_for_godmin(prefix)
  prefix.sub(/\A#{@controller_path}/, "resource").sub(/\A\//, "")
end

#template_paths(prefix) ⇒ Object



81
82
83
84
85
86
# File 'lib/godmin/resolver.rb', line 81

def template_paths(prefix)
  [
    default_path_for_godmin(prefix),
    resource_path_for_godmin(prefix)
  ]
end