Class: Sumac::Message::Exchange::ForgetNotification
- Inherits:
-
Notification
- Object
- Sumac::Message
- Sumac::Message::Exchange
- Base
- Notification
- Sumac::Message::Exchange::ForgetNotification
- Defined in:
- lib/sumac/message/exchange/forget_notification.rb
Instance Method Summary collapse
-
#initialize(connection) ⇒ ForgetNotification
constructor
A new instance of ForgetNotification.
- #invert_orgin ⇒ Object
- #parse_json_structure(json_structure) ⇒ Object
- #reference ⇒ Object
- #reference=(new_reference) ⇒ Object
- #to_json_structure ⇒ Object
Methods inherited from Base
Methods inherited from Sumac::Message::Exchange
Methods inherited from Sumac::Message
Constructor Details
#initialize(connection) ⇒ ForgetNotification
Returns a new instance of ForgetNotification.
6 7 8 9 10 |
# File 'lib/sumac/message/exchange/forget_notification.rb', line 6 def initialize(connection) super @orgin = nil @id = nil end |
Instance Method Details
#invert_orgin ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sumac/message/exchange/forget_notification.rb', line 57 def invert_orgin raise MessageError unless setup? case @orgin when 'local' @orgin = 'remote' when 'remote' @orgin = 'local' end nil end |
#parse_json_structure(json_structure) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/sumac/message/exchange/forget_notification.rb', line 12 def parse_json_structure(json_structure) raise MessageError unless json_structure.is_a?(Hash) && json_structure['message_type'] == 'exchange' && json_structure['exchange_type'] == 'forget_notification' raise MessageError unless json_structure['orgin'] == 'local' || json_structure['orgin'] == 'remote' @orgin = json_structure['orgin'] raise MessageError unless json_structure['id'].is_a?(::Integer) @id = json_structure['id'] end |
#reference ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sumac/message/exchange/forget_notification.rb', line 32 def reference raise MessageError unless setup? case @orgin when 'local' reference = @connection.local_references.from_id(@id) raise MessageError unless reference reference when 'remote' @connection.remote_references.from_id(@id) end end |
#reference=(new_reference) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sumac/message/exchange/forget_notification.rb', line 44 def reference=(new_reference) case new_reference when LocalReference @orgin = 'local' when RemoteReference @orgin = 'remote' else raise MessageError end @id = new_reference.exposed_id nil end |
#to_json_structure ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/sumac/message/exchange/forget_notification.rb', line 22 def to_json_structure raise MessageError unless setup? { 'message_type' => 'exchange', 'exchange_type' => 'forget_notification', 'orgin' => @orgin, 'id' => @id } end |