要把上次请求的数据初始化进去
初始化的时候是空,肯定不行呀
cart 实例化的时候初始化@items了没有?
顶一下
class SampleService
def m1(data)
return "You sent me '#{data}'"
end
def m2(data)
return "You sent me 2'#{data}'"
end
end
class Wrapping
def initialize(target, wrappers = [])
@target = target
@wrappers = wrappers
end
def method_missing(m, *args)
return "#{@wrappers.map(&:perform_befor).join(':')}:#{@target.send(m, *args)}:#{@wrappers.map(&:perform_after).join(':')}"
end
end
class WrapperDemo1
def perform_befor
"demo1 befor"
end
def perform_after
"demo1 after"
end
end
class WrapperDemo2
def perform_befor
"demo2 befor"
end
def perform_after
"demo2 after"
end
end
wrap = Wrapping.new(SampleService.new, [WrapperDemo1.new, WrapperDemo2.new])
p wrap.m1("something")
p wrap.m2("something")
这个算不算
class SampleService
def m1(data)
return "You sent me '#{data}'"
end
def m2(data)
return "You sent me 2'#{data}'"
end
end
class Wrapping
def initialize(target)
@target = target
end
def method_missing(m, *args)
return "Wrapped:#{@target.send(m, *args)}:Wrapped"
end
end
wrap = Wrapping.new(SampleService.new)
p wrap.m1("something")
p wrap.m2("something")
严重怀疑楼主的动机呀
低调路过
顶一下,女 ruby 好难找呀
用 emacs 的飘过,刚开始纯属装逼,现在是习惯了装逼的快感
试一下 script/rails
好,顶一下
顶一下