Class: Godmin::EngineResolver

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

Overview

Matches templates such as:

{ name: index, prefix: articles } => app/views/resource/index { name: form, prefix: articles } => app/views/resource/_form { name: title, prefix: columns } => app/views/resource/columns/_title

Instance Method Summary collapse

Methods inherited from Resolver

#_find_all, #find_templates, resolvers

Constructor Details

#initialize(controller_path, engine_wrapper) ⇒ EngineResolver

Returns a new instance of EngineResolver.



55
56
57
# File 'lib/godmin/resolver.rb', line 55

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

Instance Method Details

#resource_path_for_engine(prefix) ⇒ Object



65
66
67
# File 'lib/godmin/resolver.rb', line 65

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

#template_paths(prefix) ⇒ Object



59
60
61
62
63
# File 'lib/godmin/resolver.rb', line 59

def template_paths(prefix)
  [
    resource_path_for_engine(prefix)
  ]
end