Class: Fierce::PresenterFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/fierce/presenter_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PresenterFinder

Returns a new instance of PresenterFinder.



5
6
7
# File 'lib/fierce/presenter_finder.rb', line 5

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/fierce/presenter_finder.rb', line 3

def path
  @path
end

Instance Method Details

#file_path(base_path) ⇒ Object



9
10
11
# File 'lib/fierce/presenter_finder.rb', line 9

def file_path(base_path)
  "#{base_path}/#{path}.rb"
end

#found?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/fierce/presenter_finder.rb', line 13

def found?
  Fierce.paths.any? do |base_path|
    File.exist?(file_path(base_path))
  end
end

#performObject



19
20
21
# File 'lib/fierce/presenter_finder.rb', line 19

def perform
  presenter_class if found?
end

#presenter_classObject



23
24
25
# File 'lib/fierce/presenter_finder.rb', line 23

def presenter_class      
  "::#{path.classify}".constantize
end