Class: Cumulus::SQS::DeadLetterConfig
- Inherits:
-
Object
- Object
- Cumulus::SQS::DeadLetterConfig
- Defined in:
- lib/sqs/models/DeadLetterConfig.rb
Overview
Public: An object representing configuration for a queue’s dead letter options
Instance Attribute Summary collapse
-
#max_receives ⇒ Object
readonly
Returns the value of attribute max_receives.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#diff(aws) ⇒ Object
Public: Produce an array of differences between two DeadLetterConfig objects.
-
#initialize(json = nil) ⇒ DeadLetterConfig
constructor
Public: Constructor.
-
#populate!(aws) ⇒ Object
Public: Populate a config object with AWS configuration.
- #to_aws ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(json = nil) ⇒ DeadLetterConfig
Public: Constructor
json - a hash containing the JSON configuration for dead letter options
16 17 18 19 20 21 |
# File 'lib/sqs/models/DeadLetterConfig.rb', line 16 def initialize(json = nil) if !json.nil? @target = json["target"] @max_receives = json["max-receives"] end end |
Instance Attribute Details
#max_receives ⇒ Object (readonly)
Returns the value of attribute max_receives.
11 12 13 |
# File 'lib/sqs/models/DeadLetterConfig.rb', line 11 def max_receives @max_receives end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
10 11 12 |
# File 'lib/sqs/models/DeadLetterConfig.rb', line 10 def target @target end |
Instance Method Details
#diff(aws) ⇒ Object
Public: Produce an array of differences between two DeadLetterConfig objects
aws - the DeadLetterConfig object built from aws config
Returns an array of the DeadLetterDiffs that were found
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sqs/models/DeadLetterConfig.rb', line 54 def diff(aws) diffs = [] if @target != aws.target diffs << DeadLetterDiff.new(DeadLetterChange::TARGET, aws.target, @target) end if @max_receives != aws.max_receives diffs << DeadLetterDiff.new(DeadLetterChange::RECEIVE, aws.max_receives, @max_receives) end diffs end |
#populate!(aws) ⇒ Object
Public: Populate a config object with AWS configuration
aws - the JSON string containing dead letter attributes in AWS
40 41 42 43 44 45 46 47 |
# File 'lib/sqs/models/DeadLetterConfig.rb', line 40 def populate!(aws) attributes = JSON.parse(URI.decode(aws)) @target = SQS::queue_arns.key(attributes["deadLetterTargetArn"]) @max_receives = if attributes["maxReceiveCount"] then attributes["maxReceiveCount"].to_i end self end |
#to_aws ⇒ Object
30 31 32 33 34 35 |
# File 'lib/sqs/models/DeadLetterConfig.rb', line 30 def to_aws { "deadLetterTargetArn" => SQS::queue_arns[@target], "maxReceiveCount" => @max_receives } end |
#to_hash ⇒ Object
23 24 25 26 27 28 |
# File 'lib/sqs/models/DeadLetterConfig.rb', line 23 def to_hash { "target" => @target, "max-receives" => @max_receives, } end |