Skip to content

Commit

Permalink
Remove observers and sweepers
Browse files Browse the repository at this point in the history
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 Nov 29, 2012
1 parent e38d310 commit ccecab3
Show file tree
Hide file tree
Showing 39 changed files with 14 additions and 1,961 deletions.
7 changes: 2 additions & 5 deletions actionpack/lib/action_controller/caching.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -54,7 +52,6 @@ def cache_configured?

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

included do
extend ConfigMethods
Expand Down
116 changes: 0 additions & 116 deletions actionpack/lib/action_controller/caching/sweeping.rb

This file was deleted.

1 change: 0 additions & 1 deletion actionpack/test/abstract_unit.rb
Expand Up @@ -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

Expand Down
41 changes: 0 additions & 41 deletions actionpack/test/controller/filters_test.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 0 additions & 16 deletions actionpack/test/controller/sweeper_test.rb

This file was deleted.

2 changes: 0 additions & 2 deletions activemodel/lib/active_model.rb
Expand Up @@ -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
Expand Down
152 changes: 0 additions & 152 deletions activemodel/lib/active_model/observer_array.rb

This file was deleted.

3 comments on commit ccecab3

@rogerleite
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterwillcn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@leonelgalan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.