Class: Editserver::Response
- Inherits:
-
Object
- Object
- Editserver::Response
- Defined in:
- lib/editserver/response.rb
Instance Attribute Summary collapse
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(editor, request) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(editor, request) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 |
# File 'lib/editserver/response.rb', line 8 def initialize editor, request @editor = editor @request = request @response = Rack::Response.new end |
Instance Attribute Details
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
6 7 8 |
# File 'lib/editserver/response.rb', line 6 def editor @editor end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/editserver/response.rb', line 6 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/editserver/response.rb', line 6 def response @response end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/editserver/response.rb', line 14 def call tempfile = mktemp editor.edit tempfile.path response.write File.read(tempfile.path) response.finish rescue EditError => e response.write e.to_s response.status = 500 # server error response.finish ensure if tempfile tempfile.close tempfile.unlink end end |