Class: Relax2::Base

Inherits:
Object
  • Object
show all
Extended by:
DSL
Defined in:
lib/relax2/base.rb

Direct Known Subclasses

MainApplication

Class Method Summary collapse

Methods included from DSL

base_url, interceptor

Class Method Details

.call(request) ⇒ Object



16
17
18
# File 'lib/relax2/base.rb', line 16

def self.call(request)
  RequestContext.new(base_url: @base_url, interceptors: @interceptors).call(request)
end

.runObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/relax2/base.rb', line 20

def self.run
  from_pipe = File.pipe?($stdin)
  from_redirect = !IO.select([$stdin], [], [], 0).nil?
  body = $stdin.read if from_pipe || from_redirect

  request = Request.from(args: ARGV, body: body)

  @interceptors ||= []
  @interceptors << Interceptors.print_response if @interceptors.empty?

  call(request)
end