Skip to content
Permalink
Browse files

Remove observers and sweepers

They was extracted from a plugin.

See https://github.com/rails/rails-observers

[Rafael Mendonça França + Steve Klabnik]
  • Loading branch information...
rafaelfranca committed Oct 14, 2012
1 parent e38d310 commit ccecab3ba950a288b61a516bf9b6962e384aae0b
Showing with 14 additions and 1,961 deletions.
  1. +2 −5 actionpack/lib/action_controller/caching.rb
  2. +0 −116 actionpack/lib/action_controller/caching/sweeping.rb
  3. +0 −1 actionpack/test/abstract_unit.rb
  4. +0 −41 actionpack/test/controller/filters_test.rb
  5. +0 −16 actionpack/test/controller/sweeper_test.rb
  6. +0 −2 activemodel/lib/active_model.rb
  7. +0 −152 activemodel/lib/active_model/observer_array.rb
  8. +0 −373 activemodel/lib/active_model/observing.rb
  9. +0 −220 activemodel/test/cases/observer_array_test.rb
  10. +0 −181 activemodel/test/cases/observing_test.rb
  11. +0 −27 activemodel/test/models/observers.rb
  12. +0 −1 activerecord/lib/active_record.rb
  13. +0 −2 activerecord/lib/active_record/base.rb
  14. +0 −126 activerecord/lib/active_record/observer.rb
  15. +1 −1 activerecord/lib/active_record/persistence.rb
  16. +0 −10 activerecord/lib/active_record/railtie.rb
  17. +3 −6 activerecord/lib/active_record/relation.rb
  18. +0 −15 activerecord/lib/rails/generators/active_record/observer/observer_generator.rb
  19. +0 −4 activerecord/lib/rails/generators/active_record/observer/templates/observer.rb
  20. +1 −1 activerecord/test/cases/dirty_test.rb
  21. +0 −256 activerecord/test/cases/lifecycle_test.rb
  22. +0 −81 activerecord/test/cases/transaction_callbacks_test.rb
  23. +0 −3 guides/code/getting_started/config/application.rb
  24. +1 −66 guides/source/active_record_validations_callbacks.md
  25. +0 −98 guides/source/caching_with_rails.md
  26. +2 −2 guides/source/configuring.md
  27. +1 −1 railties/lib/rails/engine.rb
  28. +0 −2 railties/lib/rails/generators.rb
  29. +1 −1 railties/lib/rails/generators/actions.rb
  30. +2 −2 railties/lib/rails/generators/named_base.rb
  31. +0 −12 railties/lib/rails/generators/rails/observer/USAGE
  32. +0 −7 railties/lib/rails/generators/rails/observer/observer_generator.rb
  33. +0 −13 railties/lib/rails/generators/test_unit/observer/observer_generator.rb
  34. +0 −9 railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb
  35. +0 −21 railties/test/application/configuration_test.rb
  36. +0 −17 railties/test/application/console_test.rb
  37. +0 −22 railties/test/application/rake_test.rb
  38. +0 −21 railties/test/generators/namespaced_generators_test.rb
  39. +0 −27 railties/test/generators/observer_generator_test.rb
@@ -6,10 +6,10 @@ module ActionController
# \Caching is a cheap way of speeding up slow applications by keeping the result of
# calculations, renderings, and database calls around for subsequent requests.
#
# You can read more about each approach and the sweeping assistance by clicking the
# You can read more about each approach and the by clicking the
# modules below.
#
# Note: To turn off all caching and sweeping, set
# Note: To turn off all caching, set
# config.action_controller.perform_caching = false.
#
# == \Caching stores
@@ -30,8 +30,6 @@ module Caching

eager_autoload do
autoload :Fragments
autoload :Sweeper, 'action_controller/caching/sweeping'
autoload :Sweeping, 'action_controller/caching/sweeping'
end

module ConfigMethods
@@ -54,7 +52,6 @@ def cache_configured?

include ConfigMethods
include Fragments
include Sweeping if defined?(ActiveRecord)

included do
extend ConfigMethods

This file was deleted.

Oops, something went wrong.
@@ -25,7 +25,6 @@
require 'active_model'
require 'active_record'
require 'action_controller/caching'
require 'action_controller/caching/sweeping'

require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late

@@ -499,18 +499,6 @@ def filter_three

end

class ::AppSweeper < ActionController::Caching::Sweeper; end
class SweeperTestController < ActionController::Base
cache_sweeper :app_sweeper
def show
render :text => 'hello world'
end

def error
raise StandardError.new
end
end

class ImplicitActionsController < ActionController::Base
before_filter :find_only, :only => :edit
before_filter :find_except, :except => :edit
@@ -526,35 +514,6 @@ def find_except
end
end

def test_sweeper_should_not_ignore_no_method_error
sweeper = ActionController::Caching::Sweeper.send(:new)
assert_raise NoMethodError do
sweeper.send_not_defined
end
end

def test_sweeper_should_not_block_rendering
response = test_process(SweeperTestController)
assert_equal 'hello world', response.body
end

def test_sweeper_should_clean_up_if_exception_is_raised
assert_raise StandardError do
test_process(SweeperTestController, 'error')
end
assert_nil AppSweeper.instance.controller
end

def test_before_method_of_sweeper_should_always_return_true
sweeper = ActionController::Caching::Sweeper.send(:new)
assert sweeper.before(TestController.new)
end

def test_after_method_of_sweeper_should_always_return_nil
sweeper = ActionController::Caching::Sweeper.send(:new)
assert_nil sweeper.after(TestController.new)
end

def test_non_yielding_around_filters_not_returning_false_do_not_raise
controller = NonYieldingAroundFilterController.new
controller.instance_variable_set "@filter_return_value", true

This file was deleted.

Oops, something went wrong.
@@ -40,8 +40,6 @@ module ActiveModel
autoload :DeprecatedMassAssignmentSecurity
autoload :Name, 'active_model/naming'
autoload :Naming
autoload :Observer, 'active_model/observing'
autoload :Observing
autoload :SecurePassword
autoload :Serialization
autoload :TestCase

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

3 comments on commit ccecab3

@rogerleite

This comment has been minimized.

Copy link

rogerleite replied Nov 29, 2012

@peterwillcn

This comment has been minimized.

Copy link

peterwillcn replied Dec 13, 2013

rails will be slimming...
gem 'rails-observers'
cool...

@leonelgalan

This comment has been minimized.

Copy link
Contributor

leonelgalan replied Oct 7, 2016

Is there an issue or pull request in which this removal is discussed?

So far the best explanation I got it from @rafaelfranca in rails/rails-observers#2 (comment):

It was extracted from Rails because it is something that we don't use in our applications and because we don't want to encourage it as best practice, not because people use it wrong.

I'm interested in knowing what's being encouraged as the best practice? Are Active Record Callbacks the best practice? Callback Classes (Rails Guides link) could fill the void without an additional dependency too.

Please sign in to comment.
You can’t perform that action at this time.