Class: Interapp::ReceiveMessageService
- Inherits:
-
Object
- Object
- Interapp::ReceiveMessageService
- Defined in:
- app/services/interapp/receive_message_service.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#peer ⇒ Object
readonly
Returns the value of attribute peer.
-
#return_value ⇒ Object
readonly
Returns the value of attribute return_value.
Instance Method Summary collapse
-
#initialize(payload:, peer_identifier:, signature:) ⇒ ReceiveMessageService
constructor
A new instance of ReceiveMessageService.
- #perform ⇒ Object
Constructor Details
#initialize(payload:, peer_identifier:, signature:) ⇒ ReceiveMessageService
Returns a new instance of ReceiveMessageService.
5 6 7 8 9 |
# File 'app/services/interapp/receive_message_service.rb', line 5 def initialize(payload:, peer_identifier:, signature:) find_peer(peer_identifier) @message = Message.new(payload: payload, peer: @peer, signature: signature) @data = JSON.load(@message.payload) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'app/services/interapp/receive_message_service.rb', line 3 def data @data end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'app/services/interapp/receive_message_service.rb', line 3 def @message end |
#peer ⇒ Object (readonly)
Returns the value of attribute peer.
3 4 5 |
# File 'app/services/interapp/receive_message_service.rb', line 3 def peer @peer end |
#return_value ⇒ Object (readonly)
Returns the value of attribute return_value.
3 4 5 |
# File 'app/services/interapp/receive_message_service.rb', line 3 def return_value @return_value end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/services/interapp/receive_message_service.rb', line 11 def perform if @message.verify @return_value = Interapp.configuration.handler.call(data, .peer.identifier) else raise Interapp::SignatureInvalidError end rescue OpenSSL::ASN1::ASN1Error raise Interapp::SignatureInvalidError end |