I'm using Ryan Bates' excellent scope_builder to conditionally build a new named scope to use in a search() method of an Active Record model.
The example documentation shows that you can do something like the following:
# in product model
def self.search(options)
scope_builder do |builder|
builder.released.visible
builder.cheap if options[:cheap]
end
end
But, when I include the relevant version of the above code in my model and call search() with some options passed, what I get returned is an instance of ScopeBuilder::Builder and not the results of executing the chained named scope with the options I've passed, which is what I would expect.
My question is: How do I get the results of executing builder(options) instead of an instance of the builder?