Class: Meddler::Builder
- Inherits:
-
Object
show all
- Defined in:
- lib/meddler/builder.rb
Instance Method Summary
collapse
Constructor Details
#initialize(app, rules = nil, &block) ⇒ Builder
Returns a new instance of Builder.
4
5
6
7
8
9
|
# File 'lib/meddler/builder.rb', line 4
def initialize(app, rules = nil, &block)
@app = app
@target = Rack::Builder.new{}
instance_eval(&block)
@meddler = Meddler.new(@app, @on_request, @on_response, @before, @after, @target)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
11
12
13
|
# File 'lib/meddler/builder.rb', line 11
def method_missing(method, *args, &block)
@target.send(method, *args, &block)
end
|
Instance Method Details
#after(&block) ⇒ Object
30
31
32
33
|
# File 'lib/meddler/builder.rb', line 30
def after(&block)
@after ||= []
@after << block
end
|
#before(&block) ⇒ Object
25
26
27
28
|
# File 'lib/meddler/builder.rb', line 25
def before(&block)
@before ||= []
@before << block
end
|
#call(env) ⇒ Object
35
36
37
|
# File 'lib/meddler/builder.rb', line 35
def call(env)
@meddler.call(env)
end
|
#on_request(&block) ⇒ Object
15
16
17
18
|
# File 'lib/meddler/builder.rb', line 15
def on_request(&block)
@on_request ||= []
@on_request << block
end
|
#on_response(&block) ⇒ Object
20
21
22
23
|
# File 'lib/meddler/builder.rb', line 20
def on_response(&block)
@on_response ||= []
@on_response << block
end
|