Sha256: 27ed3ab5f365c699fad1ee7e759e6540c1d08b74982463e9bbc24885c4ad5b99

Contents?: true

Size: 1.15 KB

Versions: 67

Compression:

Stored size: 1.15 KB

Contents

module ResourceController
  class ActionOptions
    extend ResourceController::Accessors
    
    reader_writer  :flash
    reader_writer  :flash_now
    
    block_accessor :after, :before
    
    def initialize
      @collector = ResourceController::ResponseCollector.new
    end
    
    def response(*args, &block)
      if !args.empty? || block_given?
        @collector.clear
        args.flatten.each { |symbol| @collector.send(symbol) }
        block.call(@collector) if block_given?
      end
      
      @collector.responses
    end
    alias_method :respond_to,  :response
    alias_method :responds_to, :response
    
    def wants
      @collector
    end
    
    def dup
      returning self.class.new do |duplicate|
        duplicate.instance_variable_set(:@collector, wants.dup)
        duplicate.instance_variable_set(:@before, before.dup)       unless before.nil?
        duplicate.instance_variable_set(:@after, after.dup)         unless after.nil?
        duplicate.instance_variable_set(:@flash, flash.dup)         unless flash.nil?
        duplicate.instance_variable_set(:@flash_now, flash_now.dup) unless flash_now.nil?
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 19 rubygems

Version Path
akitaonrails-resource_controller-0.5.2 lib/resource_controller/action_options.rb
akitaonrails-resource_controller-0.5.3 lib/resource_controller/action_options.rb
csmosx-resource_controller-0.6.6 lib/resource_controller/action_options.rb
csmosx-resource_controller-0.6.7 lib/resource_controller/action_options.rb
dkubb-resource_controller-0.6.5 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.4.10 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.4.12 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.4.9 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.5.1 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.5.2 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.5.3 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.5.5 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.5.6 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.6.0 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.6.1 lib/resource_controller/action_options.rb
giraffesoft-resource_controller-0.6.5 lib/resource_controller/action_options.rb
jeffrafter-resource_controller-0.5.5 lib/resource_controller/action_options.rb
kdmny-spree-0.0.1 vendor/plugins/resource_controller/lib/resource_controller/action_options.rb
korin-resource_controller-0.5.3 lib/resource_controller/action_options.rb
maser-resource_controller-0.6.6 lib/resource_controller/action_options.rb