Class: SubZero::Message
- Inherits:
-
Object
- Object
- SubZero::Message
- Includes:
- Parser, Validations
- Defined in:
- lib/sub_zero/message.rb,
lib/sub_zero/message/parser.rb,
lib/sub_zero/message/validations.rb
Defined Under Namespace
Modules: Parser, Validations
Instance Attribute Summary collapse
-
#options ⇒ Object
(also: #routing_info)
Returns the value of attribute options.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#rid ⇒ Object
Returns the value of attribute rid.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subtype ⇒ Object
(also: #sid)
Returns the value of attribute subtype.
-
#type ⇒ Object
Returns the value of attribute type.
-
#verb ⇒ Object
Returns the value of attribute verb.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #heartbeat? ⇒ Boolean
-
#initialize(args = {}) ⇒ Message
constructor
A new instance of Message.
- #request? ⇒ Boolean
- #response? ⇒ Boolean
- #success? ⇒ Boolean
Methods included from Validations
Methods included from Parser
Constructor Details
#initialize(args = {}) ⇒ Message
Returns a new instance of Message.
17 18 19 20 21 22 23 |
# File 'lib/sub_zero/message.rb', line 17 def initialize args = {} @type, @subtype = args.values_at(:type, :subtype) @rid = args[:rid] || SecureRandom.uuid @verb, @status = args.values_at(:verb, :status) @payload = args[:payload] || {} = args[:options] || {} end |
Instance Attribute Details
#options ⇒ Object Also known as: routing_info
Returns the value of attribute options.
9 10 11 |
# File 'lib/sub_zero/message.rb', line 9 def end |
#payload ⇒ Object
Returns the value of attribute payload.
9 10 11 |
# File 'lib/sub_zero/message.rb', line 9 def payload @payload end |
#rid ⇒ Object
Returns the value of attribute rid.
9 10 11 |
# File 'lib/sub_zero/message.rb', line 9 def rid @rid end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/sub_zero/message.rb', line 9 def status @status end |
#subtype ⇒ Object Also known as: sid
Returns the value of attribute subtype.
9 10 11 |
# File 'lib/sub_zero/message.rb', line 9 def subtype @subtype end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/sub_zero/message.rb', line 9 def type @type end |
#verb ⇒ Object
Returns the value of attribute verb.
9 10 11 |
# File 'lib/sub_zero/message.rb', line 9 def verb @verb end |
Instance Method Details
#error? ⇒ Boolean
44 45 46 |
# File 'lib/sub_zero/message.rb', line 44 def error? status == 'NOK' end |
#heartbeat? ⇒ Boolean
28 29 30 |
# File 'lib/sub_zero/message.rb', line 28 def heartbeat? verb == 'PONG' end |
#request? ⇒ Boolean
32 33 34 |
# File 'lib/sub_zero/message.rb', line 32 def request? status.blank? end |
#response? ⇒ Boolean
36 37 38 |
# File 'lib/sub_zero/message.rb', line 36 def response? not request? end |
#success? ⇒ Boolean
40 41 42 |
# File 'lib/sub_zero/message.rb', line 40 def success? status == 'OK' end |