Skip to content

Commit

Permalink
Replace #before_filter with #before_action
Browse files Browse the repository at this point in the history
  • Loading branch information
buren authored and iNecas committed Feb 17, 2017
1 parent 2a228ef commit 08be240
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ default_version
validate
Parameters validation is turned off when set to false. When set to
``:explicitly``, you must invoke parameter validation yourself by calling
controller method ``apipie_validations`` (typically in a before_filter).
controller method ``apipie_validations`` (typically in a before_action).
When set to ``:implicitly`` (or just true), your controller's action
methods are wrapped with generated methods which call ``apipie_validations``,
and then call the action method. (``:implicitly`` by default)
Expand Down Expand Up @@ -729,17 +729,17 @@ is raised and can be rescued and processed. It contains a description
of the parameter value expectations. Validations can be turned off
in the configuration file.

Parameter validation normally happens after before_filters, just before
Parameter validation normally happens after before_actions, just before
your controller method is invoked. If you prefer to control when parameter
validation occurs, set the configuration parameter ``validate`` to ``:explicitly``.
You must then call the ``apipie_validations`` method yourself, e.g.:

.. code:: ruby
before_filter: :apipie_validations
before_action: :apipie_validations
This is useful if you have before_filters which use parameter values: just add them
after the ``apipie_validations`` before_filter.
This is useful if you have before_actions which use parameter values: just add them
after the ``apipie_validations`` before_action.

TypeValidator
-------------
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/apipie/apipies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class ApipiesController < ActionController::Base

layout Apipie.configuration.layout

around_filter :set_script_name
before_filter :authenticate
around_action :set_script_name
before_action :authenticate

def authenticate
if Apipie.configuration.authenticate
Expand Down
3 changes: 1 addition & 2 deletions lib/apipie/extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
class Apipie::Railtie
initializer 'apipie.extractor' do |app|
ActiveSupport.on_load :action_controller do
create_filter_method = respond_to?(:before_action) ? :before_action : :before_filter
send(create_filter_method) do |controller|
before_action do |controller|
if Apipie.configuration.record
Apipie::Extractor.call_recorder.analyse_controller(controller)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationController < ActionController::Base
before_filter :run_validations
before_action :run_validations

resource_description do
param :oauth, String, :desc => "Authorization", :required => false
Expand Down

0 comments on commit 08be240

Please sign in to comment.