Sha256: 0528745f66f3cb609ef73241c762b2254c907bb375293c8f5f0f78554ea80d2c

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

module Fierce
  class PresenterFinder
    attr_reader :path

    def initialize(path)
      @path = path
    end

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

    def found_base_path
      @found = Fierce.paths.map do |base_path|
        base_path if File.exist?(file_path(base_path))
      end.compact.first
    end

    def perform
      presenter_class if found_base_path
    end

    def path_to_classify
      top_module = found_base_path.split('/').last
      "#{top_module}/#{path}"
    end

    def presenter_class      
      require file_path(found_base_path)
      path_to_classify.classify.constantize
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fierce-0.1.3 lib/fierce/presenter_finder.rb