For this particular case, I don't understand. What would be the
advantage of lazy evaluation?
Take a look at how some examples are handled in Sequel with regards
to associations:
http://sequel.rubyforge.org/rdoc/files/doc/association_basics_rdoc.html
See section Association Options
So, for that particular case, a single block would be enough without
the need for a proc. Here is an example using Sequel:
many_to_one(:comments){|ds| ds.where(deleted:
false).order(:created_at) }
Procs would be useful for some cases where you depend on some
dynamic data (taken from the Sequel documentation with a small typo
fix):
Artist.one_to_many :songs, dataset: -> {
Song.select(:songs.*).join(Lyric, id: :lyric_id,
id => [:composer_id, :arranger_id, :vocalist_id, :lyricist_id])
}
Artist.first.songs_dataset
# SELECT songs.* FROM songs
# INNER JOIN lyrics ON
# lyrics.id = songs.lyric_id AND
# 1 IN (composer_id, arranger_id, vocalist_id, lyricist_id)
Also, I much prefer such approach as a generalized one than the AR
'finder_sql' option in a sense that it could be more easily cascaded
with other conditions.
Am I missing something?
Cheers,
Rodrigo.