Class: EchoCraft::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/echo_craft/response.rb

Overview

Basic Response with EchoCraft Struct

Direct Known Subclasses

ServiceObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

Returns a new instance of Response.



11
12
13
14
# File 'lib/echo_craft/response.rb', line 11

def initialize
  change_status(:processing)
  @data = ::OpenStruct.new
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/echo_craft/response.rb', line 9

def data
  @data
end

#messageObject (readonly)

Returns the value of attribute message.



9
10
11
# File 'lib/echo_craft/response.rb', line 9

def message
  @message
end

#statusObject

Returns the value of attribute status.



9
10
11
# File 'lib/echo_craft/response.rb', line 9

def status
  @status
end

Instance Method Details

#change_status(status) ⇒ Object



20
21
22
23
24
# File 'lib/echo_craft/response.rb', line 20

def change_status(status)
  @status = ::Rack::Utils.status_code(status)
  @message = ::Rack::Utils::HTTP_STATUS_CODES[@status]
  @status
end