Class: Grenache::ServiceMessage
- Inherits:
-
Object
- Object
- Grenache::ServiceMessage
- Defined in:
- lib/grenache/service_message.rb
Overview
Message used by services
Instance Attribute Summary collapse
-
#err ⇒ Object
Returns the value of attribute err.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#rid ⇒ Object
Returns the value of attribute rid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(payload, err = nil, rid = nil) ⇒ ServiceMessage
constructor
A new instance of ServiceMessage.
- #to_json ⇒ Object
Constructor Details
#initialize(payload, err = nil, rid = nil) ⇒ ServiceMessage
Returns a new instance of ServiceMessage.
6 7 8 9 10 |
# File 'lib/grenache/service_message.rb', line 6 def initialize(payload, err=nil, rid=nil) @payload = payload @err = err @rid = rid || SecureRandom.uuid end |
Instance Attribute Details
#err ⇒ Object
Returns the value of attribute err.
4 5 6 |
# File 'lib/grenache/service_message.rb', line 4 def err @err end |
#payload ⇒ Object
Returns the value of attribute payload.
4 5 6 |
# File 'lib/grenache/service_message.rb', line 4 def payload @payload end |
#rid ⇒ Object
Returns the value of attribute rid.
4 5 6 |
# File 'lib/grenache/service_message.rb', line 4 def rid @rid end |
Class Method Details
.parse(json) ⇒ Object
16 17 18 19 |
# File 'lib/grenache/service_message.rb', line 16 def self.parse(json) rid, err, payload = Oj.load(json) new(payload, err, rid) end |
Instance Method Details
#to_json ⇒ Object
12 13 14 |
# File 'lib/grenache/service_message.rb', line 12 def to_json Oj.dump([@rid,@err,@payload]) end |