Created
December 28, 2012 00:23
-
-
Save maeharin/4393457 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
class M1 | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
env = env + '1' | |
res = @app.call(env) | |
res = res + '6' | |
end | |
end | |
class M2 | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
env = env + '2' | |
res = @app.call(env) | |
res = res + '5' | |
end | |
end | |
class App | |
def call(env) | |
env = env + '3' | |
res = env + '4' | |
end | |
end | |
p M1.new(M2.new(App.new)).call 'request' | |
# 以下と同義 | |
#app = App.new | |
#m2 = M2.new app | |
#m1 = M1.new m2 | |
#p m1.call 'request' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment