Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/never_block/frameworks/rails.rb

Class Method Summary collapse

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 "def allowblock_\#{action}\nstatus = Fiber.current[:neverblock]\nFiber.current[:neverblock] = false\nyield\nFiber.current[:neverblock] = status\nend\naround_filter :allowblock_\#{action}, :only => [:\#{action}]\n"
  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 "def neverblock_\#{action}\nstatus = Fiber.current[:neverblock]\nFiber.current[:neverblock] = true\nyield\nFiber.current[:neverblock] = status\nend\naround_filter :allowblock_\#{action}, :only => [:\#{action}]\n"
  end
end