On Monday 20 April 2009, Zach Dennis wrote:
> > I don't agress. Both classes have distinct, although related
> > purposes. RequestCondition implements the translation from request
> > parameters to #find-options. QueryScope(Builder) fits it in with
> > ActionController and adds syntactic sugar. The former is easy to
> > spec, for the latter, I've been to lazy to figure out a good way.
>
> I'm just suggesting that RequestCondition and QueryScopeBuilder are
> encapsulated behind RequestToQueryTranslator, so your controller
> doesn't have to know about both of them. Your controller doesn't
> actually care about request conditioners and query scope builders. It
> only cares that it can translate a request to a query so it can be
> used to set the scope on the model.
That's already the case. Both of these classes are only internally used
by module QueryScope, which is the only thing a controller sees:
class PeopleController < ApplicationController
include QueryScope
query_scope :only => :index do
# Only allow to filter and order by the
# virtual name attribute.
# This attribute is mapped onto the real
# firstname and lastname attributes.
allow :name
condition :name =>
"LOWER(firstname || ' ' || lastname) :op LOWER(?)"
order :name => "lastname :dir, firstname :dir"
end
Michael.
--
Michael Schuerig
mailto:[email protected]
http://www.schuerig.de/michael/
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users