class Netfira::WebConnect::RackApp::Action::Version8::Web

Constants

SEARCH_PATH
WEB_BASE

Public Instance Methods

call() click to toggle source
# File lib/netfira/web_connect/rack_app/actions/version_8/web.rb, line 8
def call
  allow :get
  raise NotFound unless path
  path = self.path.join '/'
  options = SEARCH_PATH.map do |access, dir|
    ['', '.erb'].map do |extension|
      [access, dir.join(path + extension)]
    end
  end.flatten(1).select { |option| option[1].exist? }
  raise NotFound if options.empty?
  raise InternalServerError, "Ambiguous file name (#{options.length} variations)" unless options.length == 1
  send_file options.first.last
end