Class: RubyWolf::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_wolf/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, connection, &callback) ⇒ Handler

Returns a new instance of Handler.



7
8
9
10
11
12
13
14
# File 'lib/ruby_wolf/handler.rb', line 7

def initialize(app, connection, &callback)
  @app = app
  @env = {}
  @connection = connection
  @response = ''

  @callback = callback
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



5
6
7
# File 'lib/ruby_wolf/handler.rb', line 5

def app
  @app
end

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/ruby_wolf/handler.rb', line 5

def connection
  @connection
end

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/ruby_wolf/handler.rb', line 5

def env
  @env
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/ruby_wolf/handler.rb', line 5

def response
  @response
end

Instance Method Details

#processObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby_wolf/handler.rb', line 16

def process
  prepare_rack_env
  log_request
  process_request
  compose_response
  log_response

  @callback.call(response) if @callback
  @response
end