Class: Fog::Google::Pubsub::ReceivedMessage

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/google/models/pubsub/received_message.rb

Overview

Represents a ReceivedMessage retrieved from a Google Pubsub subscription. Note that ReceivedMessages are immutable.

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ ReceivedMessage

Returns a new instance of ReceivedMessage.



15
16
17
18
19
20
21
# File 'lib/fog/google/models/pubsub/received_message.rb', line 15

def initialize(new_attributes = {})
  # Here we secretly store the subscription name we were received on
  # in order to support #acknowledge
  attributes = new_attributes.clone
  @subscription_name = attributes.delete(:subscription_name)
  super(attributes)
end

Instance Method Details

#acknowledgeObject

Acknowledges a message.



26
27
28
29
30
31
# File 'lib/fog/google/models/pubsub/received_message.rb', line 26

def acknowledge
  requires :ack_id

  service.acknowledge_subscription(@subscription_name, [ack_id])
  nil
end

#reloadObject



33
34
35
36
# File 'lib/fog/google/models/pubsub/received_message.rb', line 33

def reload
  # Message is immutable - do nothing
  Fog::Logger.warning("#reload called on immutable ReceivedMessage")
end