Class: Ramaze::Current

Inherits:
Object show all
Extended by:
Trinity
Includes:
Trinity
Defined in:
lib/ramaze/current.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StateAccessor

each, #state_accessor, #state_reader, #state_writer

Constructor Details

#initialize(app) ⇒ Current

Returns a new instance of Current.



10
11
12
# File 'lib/ramaze/current.rb', line 10

def initialize(app)
  @app = app
end

Class Method Details

.call(env) ⇒ Object



42
43
# File 'lib/ramaze/current.rb', line 42

def self.call(env)
end

Instance Method Details

#after_callObject



48
49
# File 'lib/ramaze/current.rb', line 48

def after_call
end

#before_callObject



45
46
# File 'lib/ramaze/current.rb', line 45

def before_call
end

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/ramaze/current.rb', line 14

def call(env)
  setup(env)
  before_call
  record

  @app.call(env)
  finish
ensure
  after_call
end

#finishObject



37
38
39
40
# File 'lib/ramaze/current.rb', line 37

def finish
  session.finish if session
  response.finish
end

#recordObject



25
26
27
28
29
# File 'lib/ramaze/current.rb', line 25

def record
  return unless filter = Global.record
  request = Current.request
  Record << request if filter.call(request)
end

#setup(env) ⇒ Object



31
32
33
34
35
# File 'lib/ramaze/current.rb', line 31

def setup(env)
  self.request = Request.new(env)
  self.response = Response.new
  self.session = Session.new
end