instance_eval in Sunspot

20 views
Skip to first unread message

Dmitriy Dzema

unread,
Nov 18, 2009, 8:06:42 AM11/18/09
to Sunspot
Hi,

I was showing sunspot to several people and found they are stuck with
instance_eval in DSL. I have described this in my blog and proposed a
solution for the problem.

Here is the blog post: http://blog.dzema.name/2009/11/ruby-dsl-and-instance_eval

What do you think about this solution? Should we implement it in
Sunspot?

Thanks.

Mat Brown

unread,
Nov 18, 2009, 8:14:28 AM11/18/09
to ruby-s...@googlegroups.com
All - I have a few thoughts on this that I'll send out once I get a
chance to play around a bit more with Dmitriy's proposed solution -
but please don't hesitate to join in this conversation!
> --
>
> You received this message because you are subscribed to the Google Groups "Sunspot" group.
> To post to this group, send email to ruby-s...@googlegroups.com.
> To unsubscribe from this group, send email to ruby-sunspot...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ruby-sunspot?hl=.
>
>
>

Jeff Tucker

unread,
Nov 20, 2009, 11:50:39 AM11/20/09
to Sunspot
Hi all,

This is my first post to this board, and I'd like to start by issuing
a huge thanks to everyone working on this library. I love it!

I admit that I ran into the issue described in Dmitriy's post. After
some digging, I found a note in Sunspot#search indicating to pass an
arg to the block, so my searches look like:

Sunspot.search(Article) do |query|
query.keywords params[:query]
end

This solves the problem, but at the expense of the elegance of
Sunspot's DSL. Dmitriy's solution makes sense in reading it over,
though I haven't played with it yet. As for the potential
method_missing errors -- how about wrapping it in a custom
Sunspot::NoMethodInContextError "Unable to find #{method_name} in #
{@context}" error? This would let developers know that the error came
from within Sunspot, but only because the method they specified in the
DSL wasn't found.

Thanks again!

Jeff

On Nov 18, 8:14 am, Mat Brown <m...@patch.com> wrote:
> All - I have a few thoughts on this that I'll send out once I get a
> chance to play around a bit more with Dmitriy's proposed solution -
> but please don't hesitate to join in this conversation!
>
Reply all
Reply to author
Forward
0 new messages