Class: ResourceController::ActionOptions

Inherits:
Object
  • Object
show all
Extended by:
Accessors
Defined in:
lib/resource_controller/action_options.rb

Instance Method Summary collapse

Constructor Details

#initializeActionOptions

Returns a new instance of ActionOptions.



10
11
12
# File 'lib/resource_controller/action_options.rb', line 10

def initialize
  @collector = ResourceController::ResponseCollector.new
end

Instance Method Details

#dupObject



30
31
32
33
34
35
36
37
38
# File 'lib/resource_controller/action_options.rb', line 30

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

#response(*args, &block) ⇒ Object Also known as: respond_to, responds_to



14
15
16
17
18
19
20
21
22
# File 'lib/resource_controller/action_options.rb', line 14

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

#wantsObject



26
27
28
# File 'lib/resource_controller/action_options.rb', line 26

def wants
  @collector
end