Module: Ramaze::Current

Extended by:
Trinity
Defined in:
lib/ramaze/current.rb

Class Method Summary collapse

Class Method Details

.after(&block) ⇒ Object



53
54
55
56
# File 'lib/ramaze/current.rb', line 53

def after(&block)
  @after = block if block
  @after
end

.after_callObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/ramaze/current.rb', line 58

def after_call
  if after
    begin
      after.call
    rescue Object => e
      Ramaze::Log.error e
      raise
    end
  end
end

.before(&block) ⇒ Object



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

def before(&block)
  @before = block if block
  @before
end

.before_callObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/ramaze/current.rb', line 42

def before_call
  if before
    begin
      before.call
    rescue Object => e
      Ramaze::Log.error e
      raise
    end
  end
end

.call(env) ⇒ Object



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

def call(env)
  setup(env)
  before_call

  if filter = Global.record
    request = Current.request
    Record << request if filter[request]
  end

  Dispatcher.handle

  finish
ensure
  after_call
end

.finishObject



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

def finish
  session.finish if session
  response.finish
end

.setup(env) ⇒ Object



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

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