Module: Jackal::Cfn::Resource::InheritedValidity

Defined in:
lib/jackal-cfn/resource.rb

Overview

Validity method for subclasses

Instance Method Summary collapse

Instance Method Details

#valid?(message) ⇒ TrueClass, FalseClass

Determine message validity

Parameters:

  • message (Carnivore::Message)

Returns:

  • (TrueClass, FalseClass)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jackal-cfn/resource.rb', line 15

def valid?(message)
  super do |payload|
    data = payload.fetch(:data, :cfn_resource, Smash.new)
    resource_type = data[:resource_type].to_s.split('::').last
    result = data[:origin_type] == 'Notification' &&
      data[:origin_subject].to_s.downcase.include?('cloudformation custom resource') &&
      self.class.to_s.split('::').last == resource_type
    if(result && block_given?)
      yield payload
    else
      result
    end
  end
end