Module: ActionController::Filters::InstanceMethods

Defined in:
lib/action_controller/filters.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



610
611
612
613
614
615
616
# File 'lib/action_controller/filters.rb', line 610

def self.included(base)
  base.class_eval do
    alias_method_chain :perform_action, :filters
    alias_method_chain :process, :filters
    alias_method_chain :process_cleanup, :filters
  end
end

Instance Method Details

#call_filter(chain, index) ⇒ Object



631
632
633
634
635
636
637
638
639
640
641
642
# File 'lib/action_controller/filters.rb', line 631

def call_filter(chain, index)
  return (performed? || perform_action_without_filters) if index >= chain.size
  filter = chain[index]
  return call_filter(chain, index.next) if self.class.filter_excluded_from_action?(filter,action_name)

  halted = false
  filter.call(self) do
    halted = call_filter(chain, index.next)
  end
  halt_filter_chain(filter.filter, :no_yield) if halted == false unless @before_filter_chain_aborted
  halted
end

#filter_chainObject



627
628
629
# File 'lib/action_controller/filters.rb', line 627

def filter_chain
  self.class.filter_chain
end

#halt_filter_chain(filter, reason) ⇒ Object



644
645
646
647
648
649
650
651
652
653
654
655
# File 'lib/action_controller/filters.rb', line 644

def halt_filter_chain(filter, reason)
  if logger
    case reason
    when :no_yield
      logger.info "Filter chain halted as [#{filter.inspect}] did not yield."
    when :returned_false
      logger.info "Filter chain halted as [#{filter.inspect}] returned false."
    end
  end
  @before_filter_chain_aborted = true
  return false
end

#perform_action_with_filtersObject



618
619
620
# File 'lib/action_controller/filters.rb', line 618

def perform_action_with_filters
  call_filter(self.class.filter_chain, 0)
end

#process_with_filters(request, response, method = :perform_action, *arguments) ⇒ Object

:nodoc:



622
623
624
625
# File 'lib/action_controller/filters.rb', line 622

def process_with_filters(request, response, method = :perform_action, *arguments) #:nodoc:
  @before_filter_chain_aborted = false
  process_without_filters(request, response, method, *arguments)
end