Class: Resourcelogic::ResponseCollector
- Inherits:
-
Object
- Object
- Resourcelogic::ResponseCollector
- Defined in:
- lib/resourcelogic/response_collector.rb
Instance Attribute Summary collapse
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Instance Method Summary collapse
- #[](symbol) ⇒ Object
- #dup ⇒ Object
-
#initialize ⇒ ResponseCollector
constructor
A new instance of ResponseCollector.
- #method_missing(method_name, &block) ⇒ Object
Constructor Details
#initialize ⇒ ResponseCollector
Returns a new instance of ResponseCollector.
8 9 10 |
# File 'lib/resourcelogic/response_collector.rb', line 8 def initialize @responses = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/resourcelogic/response_collector.rb', line 12 def method_missing(method_name, &block) @responses.delete self[method_name] value = [method_name, block || nil] if method_name == :html @responses.unshift(value) else @responses << value end end |
Instance Attribute Details
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
4 5 6 |
# File 'lib/resourcelogic/response_collector.rb', line 4 def responses @responses end |
Instance Method Details
#[](symbol) ⇒ Object
22 23 24 |
# File 'lib/resourcelogic/response_collector.rb', line 22 def [](symbol) @responses.find { |method, block| method == symbol } end |
#dup ⇒ Object
26 27 28 29 30 |
# File 'lib/resourcelogic/response_collector.rb', line 26 def dup returning ResponseCollector.new do |duplicate| duplicate.instance_variable_set(:@responses, responses.dup) end end |