lib/rails_current.rb in rails_current-1.1.0 vs lib/rails_current.rb in rails_current-1.2.0

- old
+ new

@@ -1,9 +1,11 @@ require 'map' module Current - def Current.version() '1.1.0' end + def Current.version + '1.2.0' + end def Current.data Thread.current[:current] ||= Map.new end @@ -49,12 +51,12 @@ define_method(name + '=') do |value| data[name] = value end - define_method(name + '?') do |value| - data[name] + define_method(name + '?') do |*args| + send(name) end end end end @@ -104,33 +106,19 @@ nil end end end - Code = proc do - def method_missing(method, *args, &block) - case method.to_s - when /^current_(.*)$/ - msg = $1 - Current.send(msg, *args, &block) - else - super - end + def method_missing(method, *args, &block) + case method.to_s + when /^current_(.*)$/ + msg = $1 + Current.send(msg, *args, &block) + else + super end end - - def Current.included(other) - super - ensure - other.send(:module_eval, &Code) - end - - def Current.extend_object(object) - super - ensure - object.send(:instance_eval, &Code) - end end def Current(*args, &block) Current.attribute(*args, &block) end @@ -145,20 +133,28 @@ ::ActionController::Base.module_eval do before_filter do |controller| Current.clear Current.controller = controller end - end + end if defined?(::ActionController::Base) end end if defined?(Rails::Engine) class Engine < Rails::Engine config.before_initialize do Current.install_before_filter! end end + else + Current.install_before_filter! end end -Rails_current = Current +::Rails_current = ::Current + +BEGIN { + Object.send(:remove_const, :Current) if defined?(::Current) + Object.send(:remove_const, :Rails_current) if defined?(::Rails_current) +} +