Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remove InstanceMethods deprecation warning #25

Merged
merged 1 commit into from

6 participants

@leereilly

Removes the following:

DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in NoPeepingToms instead. (called from include at /Volumes/GitHub/no-peeping-toms/spec/../lib/no_peeping_toms.rb:83)

Cheers,
Lee :beers:

@leereilly leereilly Remove InstanceMethods deprecation warning
Removes the following:

DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in NoPeepingToms instead. (called from include at /Volumes/GitHub/no-peeping-toms/spec/../lib/no_peeping_toms.rb:83)
e5fbd73
@greggersh

+1 to this or any of the other pull requests that take care of this issue. Dont make me bundle from a fork!

@jch

+1 bump

@patmaddox patmaddox merged commit 02421b4 into from
@patmaddox
Owner

thank you for this, Lee & all the other folks who have submitted a fix. Here it is

okay so the next step is to publish an updated gem

I'm unsure of how to proceed. Since Rails has incorporated this functionality, NPT is no longer necessary. I don't intend to maintain it. I will assume that with this commit, NPT can be considered "done", and if folks have a desire to maintain it and take over the rubygems ownership then they'll get in touch with me.

@ike-bloomfire

Hi Pat,
Just to confirm, I'm I correct in thinking that I can drop the NPT gem from my Gemfile without any modification to my app and everything will still work exactly the same because Rails now has this functionality?

@patmaddox
Owner

Hi Ike, I don't know enough about the Rails implementation to confirm that. My top suggestion is to give it a whirl and see what happens, followed by getting in touch with Myron Marston, who implemented this functionality in Rails.

@ike-bloomfire
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 7, 2012
  1. @leereilly

    Remove InstanceMethods deprecation warning

    leereilly authored
    Removes the following:
    
    DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in NoPeepingToms instead. (called from include at /Volumes/GitHub/no-peeping-toms/spec/../lib/no_peeping_toms.rb:83)
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 26 deletions.
  1. +24 −26 lib/no_peeping_toms.rb
View
50 lib/no_peeping_toms.rb
@@ -45,38 +45,36 @@ def observer_enabled?(observer)
end
end
- module InstanceMethods
- # Overrides ActiveRecord#define_callbacks so that observers are only called
- # when enabled.
- #
- # This is a bit yuck being a protected method, but appears to be the cleanest
- # way so far
- def define_callbacks_with_enabled_check(klass)
- observer = self
- observer_name = observer.class.name.underscore.gsub('/', '__')
+ # Overrides ActiveRecord#define_callbacks so that observers are only called
+ # when enabled.
+ #
+ # This is a bit yuck being a protected method, but appears to be the cleanest
+ # way so far
+ def define_callbacks_with_enabled_check(klass)
+ observer = self
+ observer_name = observer.class.name.underscore.gsub('/', '__')
- ActiveRecord::Callbacks::CALLBACKS.each do |callback|
- next unless respond_to?(callback)
- callback_meth = :"_notify_#{observer_name}_for_#{callback}"
- unless klass.respond_to?(callback_meth)
- klass.send(:define_method, callback_meth) do
- observer.send(callback, self) if observer.observer_enabled?
- end
- klass.send(callback, callback_meth)
+ ActiveRecord::Callbacks::CALLBACKS.each do |callback|
+ next unless respond_to?(callback)
+ callback_meth = :"_notify_#{observer_name}_for_#{callback}"
+ unless klass.respond_to?(callback_meth)
+ klass.send(:define_method, callback_meth) do
+ observer.send(callback, self) if observer.observer_enabled?
end
+ klass.send(callback, callback_meth)
end
end
+ end
- # Enables interception of custom observer notifications, i.e.
- # notify_observers(:custom_notification)
- def update(*args, &block)
- super if observer_enabled?
- end
+ # Enables interception of custom observer notifications, i.e.
+ # notify_observers(:custom_notification)
+ def update(*args, &block)
+ super if observer_enabled?
+ end
- # Determines whether this observer should be run
- def observer_enabled?
- self.class.observer_enabled?(self)
- end
+ # Determines whether this observer should be run
+ def observer_enabled?
+ self.class.observer_enabled?(self)
end
end
Something went wrong with that request. Please try again.