Sha256: d44886a8a78f4a615704d61c4b68c2e8140af122413b8011cda78cf33549403f
Contents?: true
Size: 729 Bytes
Versions: 1
Compression:
Stored size: 729 Bytes
Contents
$LOAD_PATH.unshift('../../lib', __FILE__) require "quickl" $wrappers = [] def wrap(filter, &block) $wrappers << [ filter, block ] end def build_wrapper(command, filter, continuation) lambda{|cont| if !filter || command.instance_eval(&filter) command.instance_exec(continuation, &b) else continuation.call end } end def execute(command, &block) first = build_wrapper(command, *$wrappers.first) c = $wrappers[1..-1].inject(first){|cont,wrapper| build_wrapper(command, *wrapper) } c.call(block) end wrap(lambda{ true }){|cont| puts "wrap 1" cont.call puts "end wrap 1" } wrap(lambda{ true }){|cont| puts "wrap 2" cont.call puts "end wrap 2" } execute(self){ puts "hello" }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quickl-0.1.1 | test/wrapping.rb |