Class: RestReply

Inherits:
OpenShift::Model
  • Object
show all
Defined in:
app/models/rest_reply.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status = nil, type = nil, data = nil) ⇒ RestReply

Returns a new instance of RestReply.



5
6
7
8
9
10
11
12
# File 'app/models/rest_reply.rb', line 5

def initialize(status=nil, type=nil, data=nil)
  self.status = status
  self.type = type
  self.data = data
  self.messages = []
  self.version = $requested_api_version.to_s
  self.supported_api_versions = BaseController::SUPPORTED_API_VERSIONS
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



2
3
4
# File 'app/models/rest_reply.rb', line 2

def data
  @data
end

#messagesObject

Returns the value of attribute messages.



2
3
4
# File 'app/models/rest_reply.rb', line 2

def messages
  @messages
end

#statusObject

Returns the value of attribute status.



2
3
4
# File 'app/models/rest_reply.rb', line 2

def status
  @status
end

#supported_api_versionsObject

Returns the value of attribute supported_api_versions.



2
3
4
# File 'app/models/rest_reply.rb', line 2

def supported_api_versions
  @supported_api_versions
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'app/models/rest_reply.rb', line 2

def type
  @type
end

#versionObject

Returns the value of attribute version.



2
3
4
# File 'app/models/rest_reply.rb', line 2

def version
  @version
end

Instance Method Details

#process_result_io(result_io) ⇒ Object



14
15
16
17
18
19
20
21
# File 'app/models/rest_reply.rb', line 14

def process_result_io(result_io)
  unless result_io.nil?
    messages.push(Message.new(:debug, result_io.debugIO.string)) unless result_io.debugIO.string.empty?
    messages.push(Message.new(:info, result_io.messageIO.string)) unless result_io.messageIO.string.empty?
    messages.push(Message.new(:error, result_io.errorIO.string)) unless result_io.errorIO.string.empty?
    messages.push(Message.new(:result, result_io.resultIO.string)) unless result_io.resultIO.string.empty?    
  end
end

#to_xml(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
# File 'app/models/rest_reply.rb', line 23

def to_xml(options={})
  options[:tag_name] = "response"
  if not self.data.kind_of?Enumerable
    new_data = self.data
    self.data = [new_data]
  end
  super(options)
end