Skip to content

Commit

Permalink
[#839] [#873] fix chained scopes, as well as fix the original patch f…
Browse files Browse the repository at this point in the history
…or bug #839 so that it works with :include and 1.9.2
  • Loading branch information
bryanlarsen committed Nov 27, 2010
1 parent 51b336c commit 9bb733f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions hobo/lib/hobo/scopes/named_scope_extensions.rb
Expand Up @@ -6,21 +6,18 @@ class Scope

include Hobo::Scopes::ApplyScopes

def respond_to?(method, include_private=false)
super || scopes.include?(method) || proxy_scope.respond_to?(method, include_private)
def respond_to_with_hobo_scopes?(method, include_private=false)
scopes.include?(method) || proxy_scope.respond_to?(method, include_private) || respond_to_without_hobo_scopes?(method, include_private)
end
alias_method_chain :respond_to?, :hobo_scopes

private

def method_missing(method, *args, &block)
if scopes.include?(method)
scopes[method].call(self, *args)
else
with_scope :find => proxy_options do
proxy_scope.send(method, *args, &block)
end
end
def method_missing_with_hobo_scopes(method, *args, &block)
respond_to?(method) # required for side effects, see LH#839
method_missing_without_hobo_scopes(method, *args, &block)
end
alias_method_chain :method_missing, :hobo_scopes

end
end
Expand Down

0 comments on commit 9bb733f

Please sign in to comment.