Class: Bemer::PathResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/bemer/path_resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ PathResolver

Returns a new instance of PathResolver.



5
6
7
# File 'lib/bemer/path_resolver.rb', line 5

def initialize(view)
  @view = view
end

Instance Method Details

#resolve(name, partial = false) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/bemer/path_resolver.rb', line 9

def resolve(name, partial = false)
  virtual_path = view.instance_variable_get(:@virtual_path)
  directory    = [File.dirname(virtual_path)]
  file_name    = name.to_s

  return file_name unless view.lookup_context.exists?(file_name, directory, partial)

  File.join(directory, file_name).to_s
end