lib/applix.rb in applix-0.4.11 vs lib/applix.rb in applix-0.4.12

- old
+ new

@@ -103,20 +103,32 @@ def epilog &blk @epilog_cb = blk end + # opts[:argsloop], the target for any, may be be class or an object. In case + # of class we instantiate an object from it, other we use the object itself def any(opts = {}, &blk) if(app = opts[:argsloop]) + blk = lambda do |*args, opts| + # instantiate or assign target object before first usage + target = (app.is_a? Class) ? app.new(opts) : app + while(args && 0 < args.size) do args = begin if(op = args.shift) puts " --(#{op})-- (#{args.join ', '})" - app.send(op, args, opts) + if(target == app) + # object target + target.send(op, args, opts) + else + # object instance created from class target + target.send(op, *args) + end end rescue ArgumentError => e - app.send(op, opts) + target.send(op, opts) end end end end