Class: Rack::App::CLI::Fetcher::Server

Inherits:
Rackup::Server
  • Object
show all
Defined in:
lib/rack/app/cli/fetcher/server.rb

Defined Under Namespace

Classes: Options

Constant Summary collapse

Abort =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#abort(*messages) ⇒ Object

Raises:



31
32
33
# File 'lib/rack/app/cli/fetcher/server.rb', line 31

def abort(*messages)
  raise(Abort)
end

#app ⇒ Object



25
26
27
28
29
# File 'lib/rack/app/cli/fetcher/server.rb', line 25

def app
  super
rescue Abort
  Class.new(Rack::App)
end

#get_rack_app ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rack/app/cli/fetcher/server.rb', line 4

def get_rack_app
  app_class = self.app
  last_app = nil
  until app_class.is_a?(Class) && app_class <= Rack::App
    raise if app_class.__id__ == last_app.__id__

    app_class.instance_variables.each do |ivar|
      value = app_class.instance_variable_get(ivar)
      if value.respond_to?(:call) and not [Method, Proc, UnboundMethod].include?(value.class)
        app_class = value
      end
    end

    last_app = app_class
  end
  app_class
rescue
end

#opt_parser ⇒ Object



41
42
43
# File 'lib/rack/app/cli/fetcher/server.rb', line 41

def opt_parser
  Options.new
end