Sha256: a6610765658a41c6ddc6c5ecb80622202a870050cd3d70ea4c60b8b890f88abf

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 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
      self.class.new.tap 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

10 entries across 10 versions & 3 rubygems

Version Path
spree-0.11.4 vendor/plugins/resource_controller/lib/resource_controller/action_options.rb
makandra_resource_controller-0.8.0 lib/resource_controller/action_options.rb
resources_controller-1.0.4 lib/resource_controller/action_options.rb
resources_controller-1.0.3 lib/resource_controller/action_options.rb
resources_controller-1.0.2 lib/resource_controller/action_options.rb
makandra_resource_controller-0.7.3 lib/resource_controller/action_options.rb
spree-0.11.3 vendor/plugins/resource_controller/lib/resource_controller/action_options.rb
makandra_resource_controller-0.7.2 lib/resource_controller/action_options.rb
makandra_resource_controller-0.7.1 lib/resource_controller/action_options.rb
makandra_resource_controller-0.7.0 lib/resource_controller/action_options.rb