Class: Generic::Target
- Inherits:
-
Object
- Object
- Generic::Target
- Extended by:
- Forwardable
- Defined in:
- lib/generic/target.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #apply(&handler) ⇒ Object
-
#initialize(p) ⇒ Target
constructor
A new instance of Target.
Constructor Details
#initialize(p) ⇒ Target
12 13 14 15 |
# File 'lib/generic/target.rb', line 12 def initialize(p) @request = Request.new(p) @response = Response.new [], 200, {'Content-Type' => 'text/html'} end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/generic/target.rb', line 8 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/generic/target.rb', line 8 def response @response end |
Instance Method Details
#apply(&handler) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/generic/target.rb', line 42 def apply(&handler) data = instance_eval(&handler) data.respond_to?(:each) ? response.body = data : response.write(data) .finish!(response) if response end |