Skip to content

Instantly share code, notes, and snippets.

@maeharin
Created December 28, 2012 00:23
Show Gist options
  • Save maeharin/4393457 to your computer and use it in GitHub Desktop.
Save maeharin/4393457 to your computer and use it in GitHub Desktop.
#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