Skip to content

Commit

Permalink
Post c2ca73c9 compatibility. Fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkone committed Mar 28, 2011
1 parent 415cb19 commit 29bcc80
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/rails_development_boost/observable_patch.rb
Expand Up @@ -3,8 +3,21 @@ module ObservablePatch
extend self

def self.apply!
Observable.send :include, self
Observable.alias_method_chain :add_observer, :unloading
patch = self

if non_ruby_lib_implementation?
ActiveModel::Observing::ClassMethods # post c2ca73c9 compatibility
else
require 'observer'
Observable
end.class_eval do
include patch
alias_method_chain :add_observer, :unloading
end
end

def self.non_ruby_lib_implementation?
defined?(ActiveModel::Observing::ClassMethods) && ActiveModel::Observing::ClassMethods.public_instance_methods(false).map(&:to_s).include?('add_observer')
end

def add_observer_with_unloading(observer)
Expand Down

0 comments on commit 29bcc80

Please sign in to comment.