Exception: OMF::SFA::AM::Rest::ContentFoundException
- Inherits:
-
Exception
- Object
- Exception
- OMF::SFA::AM::Rest::ContentFoundException
- Defined in:
- lib/omf-sfa/am/am-rest/rest_handler.rb
Instance Method Summary collapse
-
#initialize(content, type = 'text', &block) ⇒ ContentFoundException
constructor
A new instance of ContentFoundException.
- #reply ⇒ Object
Constructor Details
#initialize(content, type = 'text', &block) ⇒ ContentFoundException
Returns a new instance of ContentFoundException.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/omf-sfa/am/am-rest/rest_handler.rb', line 94 def initialize(content, type = 'text', &block) @type = case type.to_sym when :json 'application/json' when :xml 'text/xml' when :text 'text' else (type || 'text').to_s end if content.is_a? OMF::SFA::Util::Promise @content = OMF::SFA::Util::Promise.new content.on_success do |pv| v = block ? block.call(pv) : pv @content.resolve [@type, v] end.on_error(@content).on_progress(@content) else @content = content end end |
Instance Method Details
#reply ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/omf-sfa/am/am-rest/rest_handler.rb', line 116 def reply if @content.is_a? OMF::SFA::Util::Promise require 'omf-sfa/am/am-rest/promise_handler' # delay loading as PromiseHandler sub classes this class OMF::SFA::AM::Rest::PromiseHandler.register_promise(@content) else headers = {'Content-Type' => @type} [200 , headers, @content] end end |