I have many named_scopes chained together in the normal way. So far
so good. However in a couple of cases where:
1. The named scope is actually a correlated subquery and I need to
pass additional scope into it sometimes.
2. Where the presence of a named scope in the chain should change the
behaviour of a named_scope later in the chain
I'd like the named_scope :average_discount to be able to reach back in
the proxy chain to see if :price is part of the chain (its an example
only, not the actual use case ). And potentially 'adjust' it.
#scoped_methods isn't it - that's populated only when in with_scope.
Question 1: How can I access to the current proxy chain from within a
Question 2: Can I modify the proxy_options (shudder I know) without
some serious monkey patching?
Yes, I realise I could add parameters to these lambdas, but its not
very DRY to be passing in the same parameter to several methods in the
chain either. Note I can't always predict in advance what the scope
chain will be - it can be derived based upon user input dynamically
(think of a basic reporting system where the user specifies the
attributes they want in a table).
Any ideas or alternatives?