diff options
Diffstat (limited to 'lib/arel/session.rb')
-rw-r--r-- | lib/arel/session.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/arel/session.rb b/lib/arel/session.rb index cf04e8a93a..d844cd7423 100644 --- a/lib/arel/session.rb +++ b/lib/arel/session.rb @@ -5,16 +5,22 @@ module Arel alias_method :manufacture, :new def start - if @started + if defined?(@started) && @started yield else begin @started = true @instance = manufacture - metaclass.send :alias_method, :new, :instance + metaclass.class_eval do + undef :new + alias_method :new, :instance + end yield ensure - metaclass.send :alias_method, :new, :manufacture + metaclass.class_eval do + undef :new + alias_method :new, :manufacture + end @started = false end end |