Class: ResourceMapper::ActionOptions

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

Instance Method Summary collapse

Constructor Details

#initializeActionOptions

Returns a new instance of ActionOptions.



7
8
9
# File 'lib/resource_mapper/action_options.rb', line 7

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

Instance Method Details

#dupObject



27
28
29
30
31
32
33
# File 'lib/resource_mapper/action_options.rb', line 27

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?
  end
end

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



11
12
13
14
15
16
17
18
19
# File 'lib/resource_mapper/action_options.rb', line 11

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



23
24
25
# File 'lib/resource_mapper/action_options.rb', line 23

def wants
  @collector
end