From: Jamis Buck Date: 2005-04-14T03:00:14+09:00 Subject: Re: Needle and Parameterized Services On Apr 13, 2005, at 11:08 AM, Rob Lally wrote: > Hi, > > I've been using Needle to try to create an iBatis like framework in > Ruby. I want register parameterized blocks but when I do this they > have to take the container and service point as the first two > parameters. At least I think they need to ... I'm hoping they don't, > can anyone suggest a way round it? > First off, I'm not familiar at all with iBatis--could you give a little background on that? I'm also not entirely sure I understand what you're asking, but I *think* you're saying the following: registry.register(:my_service, :model => :multiton) do |c,p,*args| # do something with *args, like: args.map { |i| "sing: #{i}" } end And you want to be able to register a block that does NOT use the first two parameters for "c" (the container) and "p" (the service point), right? Please keep in mind that even though the block accepts those first two parameters, the service point itself is parameterized only on the remaining values. In other words, when you go to query the "my_service" service, you do NOT pass in the "c" and "p" arguments--Needle does that for you. Thus: my_service = registry.my_service("do", "re", "mi") p my_service Would print ["sing: do", "sing: re", "sing: mi"] Does that make sense? Or did I miss the gist of your question? - Jamis