Browse files

Merge pull request #8455 from frodsan/actionize

Actionize: Use `_action` callbacks in documentation and code
  • Loading branch information...
2 parents 85f4956 + a53a7be commit 9cb91f93295785dd393023223976101a8dafef03 @fxn fxn committed Dec 7, 2012
View
6 actionpack/lib/abstract_controller/callbacks.rb
@@ -53,7 +53,7 @@ def skip_action_callback(*names)
skip_after_action(*names)
skip_around_action(*names)
end
-
+
alias_method :skip_filter, :skip_action_callback
# Take callback names and an optional callback proc, normalize them,
@@ -91,7 +91,7 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: prepend_before_action(names, block)
#
# Prepend a callback before actions. See _insert_callbacks for parameter details.
- # Aliased as prepend_before_action.
+ # Aliased as prepend_before_filter.
##
# :method: skip_before_action
@@ -206,7 +206,7 @@ def skip_#{callback}_action(*names)
end # end
alias_method :skip_#{callback}_filter, :skip_#{callback}_action
-
+
# *_action is the same as append_*_action
alias_method :append_#{callback}_action, :#{callback}_action # alias_method :append_before_action, :before_action
alias_method :append_#{callback}_filter, :#{callback}_action # alias_method :append_before_filter, :before_action
View
4 actionpack/lib/action_controller/metal/force_ssl.rb
@@ -32,14 +32,14 @@ module ClassMethods
# ==== Options
# * <tt>host</tt> - Redirect to a different host name
# * <tt>only</tt> - The callback should be run only for this action
- # * <tt>except</tt> - The callback should be run for all actions except this action
+ # * <tt>except</tt> - The callback should be run for all actions except this action
# * <tt>if</tt> - A symbol naming an instance method or a proc; the callback
# will be called only when it returns a true value.
# * <tt>unless</tt> - A symbol naming an instance method or a proc; the callback
# will be called only when it returns a false value.
def force_ssl(options = {})
host = options.delete(:host)
- before_filter(options) do
+ before_action(options) do
force_ssl_redirect(host)
end
end
View
10 actionpack/lib/action_controller/metal/http_authentication.rb
@@ -25,7 +25,7 @@ module HttpAuthentication
# the regular HTML interface is protected by a session approach:
#
# class ApplicationController < ActionController::Base
- # before_filter :set_account, :authenticate
+ # before_action :set_account, :authenticate
#
# protected
# def set_account
@@ -68,7 +68,7 @@ module ControllerMethods
module ClassMethods
def http_basic_authenticate_with(options = {})
- before_filter(options.except(:name, :password, :realm)) do
+ before_action(options.except(:name, :password, :realm)) do
authenticate_or_request_with_http_basic(options[:realm] || "Application") do |name, password|
name == options[:name] && password == options[:password]
end
@@ -124,7 +124,7 @@ def authentication_request(controller, realm)
# USERS = {"dhh" => "secret", #plain text password
# "dap" => Digest::MD5.hexdigest(["dap",REALM,"secret"].join(":"))} #ha1 digest password
#
- # before_filter :authenticate, except: [:index]
+ # before_action :authenticate, except: [:index]
#
# def index
# render text: "Everyone can see me!"
@@ -317,7 +317,7 @@ def opaque(secret_key)
# class PostsController < ApplicationController
# TOKEN = "secret"
#
- # before_filter :authenticate, except: [ :index ]
+ # before_action :authenticate, except: [ :index ]
#
# def index
# render text: "Everyone can see me!"
@@ -340,7 +340,7 @@ def opaque(secret_key)
# the regular HTML interface is protected by a session approach:
#
# class ApplicationController < ActionController::Base
- # before_filter :set_account, :authenticate
+ # before_action :set_account, :authenticate
#
# protected
# def set_account
View
6 actionpack/test/controller/http_basic_authentication_test.rb
@@ -2,9 +2,9 @@
class HttpBasicAuthenticationTest < ActionController::TestCase
class DummyController < ActionController::Base
- before_filter :authenticate, :only => :index
- before_filter :authenticate_with_request, :only => :display
- before_filter :authenticate_long_credentials, :only => :show
+ before_action :authenticate, only: :index
+ before_action :authenticate_with_request, only: :display
+ before_action :authenticate_long_credentials, only: :show
http_basic_authenticate_with :name => "David", :password => "Goliath", :only => :search
View
4 actionpack/test/controller/http_digest_authentication_test.rb
@@ -4,8 +4,8 @@
class HttpDigestAuthenticationTest < ActionController::TestCase
class DummyDigestController < ActionController::Base
- before_filter :authenticate, :only => :index
- before_filter :authenticate_with_request, :only => :display
+ before_action :authenticate, only: :index
+ before_action :authenticate_with_request, only: :display
USERS = { 'lifo' => 'world', 'pretty' => 'please',
'dhh' => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":"))}
View
6 actionpack/test/controller/http_token_authentication_test.rb
@@ -2,9 +2,9 @@
class HttpTokenAuthenticationTest < ActionController::TestCase
class DummyController < ActionController::Base
- before_filter :authenticate, :only => :index
- before_filter :authenticate_with_request, :only => :display
- before_filter :authenticate_long_credentials, :only => :show
+ before_action :authenticate, only: :index
+ before_action :authenticate_with_request, only: :display
+ before_action :authenticate_long_credentials, only: :show
def index
render :text => "Hello Secret"
View
2 actionpack/test/controller/log_subscriber_test.rb
@@ -13,7 +13,7 @@ class SpecialException < Exception
head :status => 406
end
- before_filter :redirector, :only => :never_executed
+ before_action :redirector, only: :never_executed
def never_executed
end
View
2 actionpack/test/controller/mime_responds_test.rb
@@ -1139,7 +1139,7 @@ class AbstractPostController < ActionController::Base
# For testing layouts which are set automatically
class PostController < AbstractPostController
- around_filter :with_iphone
+ around_action :with_iphone
def index
respond_to(:html, :iphone, :js)
View
2 actionpack/test/controller/new_base/base_test.rb
@@ -3,7 +3,7 @@
# Tests the controller dispatching happy path
module Dispatching
class SimpleController < ActionController::Base
- before_filter :authenticate
+ before_action :authenticate
def index
render :text => "success"
View
2 actionpack/test/controller/new_base/render_context_test.rb
@@ -14,7 +14,7 @@ class BasicController < ActionController::Base
include ActionView::Context
# 2) Call _prepare_context that will do the required initialization
- before_filter :_prepare_context
+ before_action :_prepare_context
def hello_world
@value = "Hello"
View
6 actionpack/test/controller/render_test.rb
@@ -37,7 +37,7 @@ def fresh
class TestController < ActionController::Base
protect_from_forgery
- before_filter :set_variable_for_layout
+ before_action :set_variable_for_layout
class LabellingFormBuilder < ActionView::Helpers::FormBuilder
end
@@ -137,7 +137,7 @@ def conditional_hello_with_cache_control_headers
def conditional_hello_with_bangs
render :action => 'hello_world'
end
- before_filter :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs
+ before_action :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs
def handle_last_modified_and_etags
fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ])
@@ -710,7 +710,7 @@ def render_call_to_partial_with_layout_in_main_layout_and_within_content_for_lay
render :action => "calling_partial_with_layout", :layout => "layouts/partial_with_layout"
end
- before_filter :only => :render_with_filters do
+ before_action only: :render_with_filters do
request.format = :xml
end
View
2 actionpack/test/controller/rescue_test.rb
@@ -68,7 +68,7 @@ class ResourceUnavailableToRescueAsString < StandardError
render :text => 'io error'
end
- before_filter(:only => :before_filter_raises) { raise 'umm nice' }
+ before_action(only: :before_filter_raises) { raise 'umm nice' }
def before_filter_raises
end
View
2 actionpack/test/controller/show_exceptions_test.rb
@@ -5,7 +5,7 @@ class ShowExceptionsController < ActionController::Base
use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
use ActionDispatch::DebugExceptions
- before_filter :only => :another_boom do
+ before_action only: :another_boom do
request.env["action_dispatch.show_detailed_exceptions"] = true
end
View
2 actionpack/test/controller/view_paths_test.rb
@@ -4,7 +4,7 @@ class ViewLoadPathsTest < ActionController::TestCase
class TestController < ActionController::Base
def self.controller_path() "test" end
- before_filter :add_view_path, :only => :hello_world_at_request_time
+ before_action :add_view_path, only: :hello_world_at_request_time
def hello_world() end
def hello_world_at_request_time() render(:action => 'hello_world') end

0 comments on commit 9cb91f9

Please sign in to comment.