Class: ActiveSupport::Callbacks::CallbackSequence
- Defined in:
 - lib/active_support/callbacks.rb
 
Overview
Execute before and after filters in a sequence instead of chaining them with nested lambda calls, see: github.com/rails/rails/issues/18011
Instance Attribute Summary collapse
- 
  
    
      #nested  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute nested.
 
Instance Method Summary collapse
- #after(after) ⇒ Object
 - #around(call_template, user_conditions) ⇒ Object
 - #before(before) ⇒ Object
 - #expand_call_template(arg, block) ⇒ Object
 - #final? ⇒ Boolean
 - 
  
    
      #initialize(nested = nil, call_template = nil, user_conditions = nil)  ⇒ CallbackSequence 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
:nodoc:.
 - #invoke_after(arg) ⇒ Object
 - #invoke_before(arg) ⇒ Object
 - #skip?(arg) ⇒ Boolean
 
Constructor Details
#initialize(nested = nil, call_template = nil, user_conditions = nil) ⇒ CallbackSequence
:nodoc:
      520 521 522 523 524 525 526 527  | 
    
      # File 'lib/active_support/callbacks.rb', line 520 def initialize(nested = nil, call_template = nil, user_conditions = nil) @nested = nested @call_template = call_template @user_conditions = user_conditions @before = nil @after = nil end  | 
  
Instance Attribute Details
#nested ⇒ Object (readonly)
Returns the value of attribute nested.
      549 550 551  | 
    
      # File 'lib/active_support/callbacks.rb', line 549 def nested @nested end  | 
  
Instance Method Details
#after(after) ⇒ Object
      535 536 537 538 539  | 
    
      # File 'lib/active_support/callbacks.rb', line 535 def after(after) @after ||= [] @after.push(after) self end  | 
  
#around(call_template, user_conditions) ⇒ Object
      541 542 543  | 
    
      # File 'lib/active_support/callbacks.rb', line 541 def around(call_template, user_conditions) CallbackSequence.new(self, call_template, user_conditions) end  | 
  
#before(before) ⇒ Object
      529 530 531 532 533  | 
    
      # File 'lib/active_support/callbacks.rb', line 529 def before(before) @before ||= [] @before.unshift(before) self end  | 
  
#expand_call_template(arg, block) ⇒ Object
      555 556 557  | 
    
      # File 'lib/active_support/callbacks.rb', line 555 def (arg, block) @call_template.(arg.target, arg.value, block) end  | 
  
#final? ⇒ Boolean
      551 552 553  | 
    
      # File 'lib/active_support/callbacks.rb', line 551 def final? !@call_template end  | 
  
#invoke_after(arg) ⇒ Object
      563 564 565  | 
    
      # File 'lib/active_support/callbacks.rb', line 563 def invoke_after(arg) @after&.each { |a| a.call(arg) } end  | 
  
#invoke_before(arg) ⇒ Object
      559 560 561  | 
    
      # File 'lib/active_support/callbacks.rb', line 559 def invoke_before(arg) @before&.each { |b| b.call(arg) } end  | 
  
#skip?(arg) ⇒ Boolean
      545 546 547  | 
    
      # File 'lib/active_support/callbacks.rb', line 545 def skip?(arg) arg.halted || !@user_conditions.all? { |c| c.call(arg.target, arg.value) } end  |