On Nov 22, 10:32 am, Joe Van Dyk <[email protected]> wrote:
> Is it possible to access sequel dataset results with dots, instead of :
> [] ?
>
> i.e.
>
> DB[:table].each do |row|
> puts row.col1
> end
>
> instead of
>
> DB[:table].each do |row|
> puts row["col1"]
> end
Not by default. Sequel::Dataset instances yield plain ruby hashes by
default, which don't implement method_missing. You can use models or
set your own row_proc if you want special behavior:
module HashMM
def method_missing(*a)
self[*a]
end
end
ds = DB[:table]
ds.row_proc = proc{|h| h.extend(HashMM)}
DB[:table].each do |row|
puts row.col1
end
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.