Class: ActionController::Base
- Inherits:
-
Object
- Object
- ActionController::Base
- Defined in:
- lib/never_block/frameworks/rails.rb
Class Method Summary collapse
-
.allowblock(*actions) ⇒ Object
Mark some actions to execute in a blocking manner overriding the default settings.
-
.neverblock(*actions) ⇒ Object
Mark some actions to execute in a non-blocking manner overriding the default settings.
Class Method Details
.allowblock(*actions) ⇒ Object
Mark some actions to execute in a blocking manner overriding the default settings. Example:
class UsersController < ApplicationController
.
allowblock :index
.
end
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/never_block/frameworks/rails.rb', line 30 def self.allowblock(*actions) actions.each do |action| class_eval <<-"end_eval" def allowblock_#{action} status = Fiber.current[:neverblock] Fiber.current[:neverblock] = false yield Fiber.current[:neverblock] = status end around_filter :allowblock_#{action}, :only => [:#{action}] end_eval end end |
.neverblock(*actions) ⇒ Object
Mark some actions to execute in a non-blocking manner overriding the default settings. Example:
class UsersController < ApplicationController
.
allowblock :index
.
end
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/never_block/frameworks/rails.rb', line 52 def self.neverblock(*actions) actions.each do |action| class_eval <<-"end_eval" def neverblock_#{action} status = Fiber.current[:neverblock] Fiber.current[:neverblock] = true yield Fiber.current[:neverblock] = status end around_filter :allowblock_#{action}, :only => [:#{action}] end_eval end end |