On Nov 26, 2:12 pm, Arnaud Leymet <[email protected]> wrote:
> I use *Sequel* <http://sequel.rubyforge.org/> as an ORM for a Ruby project.
>
> DataSets can be queried with the classical handlers: 
> SELECT<http://sequel.rubyforge.org/rdoc/classes/Sequel/Dataset.html#method-i...>,
> WHERE, etc.
>
> I manage to use the SELECT handler with the following:
>
> database[:table].select{[DATE(created_at)]} # It works, but it's static
>
> I'd like the attribute name to be variable, so I'd need something like:
>
> database[:table].select{[DATE(@created_at)]} # It doesn't work
>
> But it doesn't work...
>
> How could I achieve this?

This is because if you use a virtual row block without a block
argument, it is instance_evaled in the context of a VirtualRow
instance.  If you want to access instance variables of the outer
scope, you need to provide a block variable for the VirtualRow
instance, as then the proc is not instance_evaled:

  database[:table].select{|o| o.DATE(@created_at)}

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-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/sequel-talk?hl=en.

Reply via email to