On 09/02/10 19:32, Markus Roberts wrote:
> I am confused about a number of things with this patch; I'll pick out
> one that seems the easiest to explain in the hopes that the answer
> will allign my thinking:
> 
> I don't see how the following could work:
> 
>     def find(request)
> -        return nil unless result =
> deserialize(network(request).get(indirection2uri(request), headers))
> +        return nil unless result =
> network(request).request_get(indirection2uri(request), headers) do
> |response|
> +            return deserialize(response)
> +        end
>         result.name = request.key
>         result
>     end

What I understood is that returning a value in this block would end up
in "result". And indeed I was able to deserialize catalogs, certificates
and such, so I suppose it is working fine.

> Specifically, if the block containing "return deserialize(response)"
> is called/yielded "live" I believe it should exit from the find method
> without the result name being set to the result key, whereas if it is
> stashed and called later (after find has returned) it should produce a
> LocalJumpError.

To me it would return from the method that yields it (ie the
request_get), but that's a wild guess.

> If this code works, I'm obviously missing something.  Any idea what?

Your ruby is way better than mine, so I'd tend to trust what you say :-)

So you would write the code like this (sorry for the wrapping)?
network(request).request_get(indirection2uri(request), headers) do
|response|
 result = deserialize(response)
end
return nil unless result
result.name = request.key
result

If that's preferrable, this is an easy change.
-- 
Brice Figureau
My Blog: http://www.masterzen.fr/

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to