Class: Moon::Response::JSON::Message

Inherits:
Moon::Response::JSON show all
Defined in:
lib/moon/response/json/message.rb

Overview

Moon::Response::JSON::Message provides a simple response with one message

Instance Attribute Summary collapse

Attributes inherited from Moon::Response::JSON

#status

Instance Method Summary collapse

Methods inherited from Moon::Response::JSON

#body, #headers

Methods inherited from Base

#body, #headers, #status

Constructor Details

#initialize(status, message, id = nil) ⇒ Message

Returns a new instance of Message.



8
9
10
11
# File 'lib/moon/response/json/message.rb', line 8

def initialize(status, message, id = nil)
  @message, @id = message, id
  super status
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/moon/response/json/message.rb', line 6

def id
  @id
end

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/moon/response/json/message.rb', line 5

def message
  @message
end

Instance Method Details

#hashObject



13
14
15
16
# File 'lib/moon/response/json/message.rb', line 13

def hash
  id = self.id
  { :message => message }.merge(id ? { :id => id } : { })
end