From 7396e85398792d436c6d3c8fceec71cee8abd59f Mon Sep 17 00:00:00 2001 From: Alexey Vasiliev Date: Tue, 4 Feb 2014 15:44:20 +0200 Subject: [PATCH] Fix problem to catch NoMethodError from non receiver object --- lib/docile/fallback_context_proxy.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/docile/fallback_context_proxy.rb b/lib/docile/fallback_context_proxy.rb index ff4822c..98ceea6 100644 --- a/lib/docile/fallback_context_proxy.rb +++ b/lib/docile/fallback_context_proxy.rb @@ -53,9 +53,11 @@ module Docile # Proxy all methods, excluding {NON_PROXIED_METHODS}, first to `receiver` # and then to `fallback` if not found. def method_missing(method, *args, &block) - @__receiver__.__send__(method.to_sym, *args, &block) - rescue ::NoMethodError => _ - @__fallback__.__send__(method.to_sym, *args, &block) + if @__receiver__.methods.include?(method.to_sym) + @__receiver__.__send__(method.to_sym, *args, &block) + else + @__fallback__.__send__(method.to_sym, *args, &block) + end end end end