Class: Fierce::PresenterFinder
- Inherits:
-
Object
- Object
- Fierce::PresenterFinder
- Defined in:
- lib/fierce/presenter_finder.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #file_path(base_path) ⇒ Object
- #found ⇒ Object
-
#initialize(path) ⇒ PresenterFinder
constructor
A new instance of PresenterFinder.
- #path_to_classify ⇒ Object
- #perform ⇒ Object
- #presenter_class ⇒ Object
- #root ⇒ Object
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
#path ⇒ Object (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
13 14 15 |
# File 'lib/fierce/presenter_finder.rb', line 13 def file_path(base_path) "#{base_path}/#{path}.rb" end |
#found ⇒ Object
17 18 19 20 21 |
# File 'lib/fierce/presenter_finder.rb', line 17 def found @found = Fierce.paths.map do |base_path| base_path if File.exist?(file_path(base_path)) end.compact.first end |
#path_to_classify ⇒ Object
27 28 29 30 31 32 |
# File 'lib/fierce/presenter_finder.rb', line 27 def path_to_classify found .gsub(root, '') .gsub('/app', '') .gsub(/\.rb$/, '') + "/#{path}" end |
#perform ⇒ Object
23 24 25 |
# File 'lib/fierce/presenter_finder.rb', line 23 def perform presenter_class if found end |
#presenter_class ⇒ Object
34 35 36 37 |
# File 'lib/fierce/presenter_finder.rb', line 34 def presenter_class require file_path(found) path_to_classify.classify.constantize end |
#root ⇒ Object
9 10 11 |
# File 'lib/fierce/presenter_finder.rb', line 9 def root Rails.root.to_s end |