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.



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

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

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



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

def app
  @app
end

#callbackObject (readonly)

Returns the value of attribute callback.



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

def callback
  @callback
end

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

#envObject (readonly)

Returns the value of attribute env.



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

def env
  @env
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#processObject



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

def process
  prepare_rack_env
  parse_request
  generate_response
  callback.call(response) if callback
  response
end