Hi philip,
> Also, as to the Proc enhancement, I haven't thought about it and my
> head hurts...
>
> But what happens if one of the arguments is say Time.now? Will that
> get evaluated *once* or each time? That is, will you have the same
> issue you'd have if you wrote:
>
> named_scope :foo, :conditions => ["created_at >= ?", 5.days.ago]
>
> Where 5.days.ago gets evaulated *once* and never changes until you
> restart (hence the need to passing a lambda into your namedscope).
as far as I can see, my code would never be called in those
circumstances, as 5.days doesn't evaluate to a symbol, does it?
Comparing Rails' original implementation
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end
with the improved(?) one:
def to_proc
@to_proc ||= Proc.new { |*args| args.shift.__send__(self, *args) }
end
you have the same values "going" into the Proc, namely the symbol
(i.e. self). What I don't know The question is more if there is
something "invisible" going on in there?
Speaking of questions: does anyone know in what circumstances the
*args array can hold any values at all?
regards,
/eno
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---