Class: CloudFormation::Bridge::Resources::Base

Inherits:
Object
  • Object
show all
Includes:
Names
Defined in:
lib/cloud_formation/bridge/resources/base.rb

Instance Method Summary collapse

Instance Method Details

#require_fields(request, *fields) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cloud_formation/bridge/resources/base.rb', line 12

def require_fields(request, *fields)
  empty_fields = fields.flatten.select do |field|
    request.resource_properties[field].nil? ||
      request.resource_properties[field].strip.empty?
  end

  unless empty_fields.empty?
    raise ArgumentError.new("The fields #{empty_fields.inspect} are required for this resource")
  end

end

#update(request) ⇒ Object



24
25
26
27
# File 'lib/cloud_formation/bridge/resources/base.rb', line 24

def update(request)
  raise CloudFormation::Bridge::OperationNotImplementedError.new(
          "The resource #{self.class.name} does not implement the update operation - #{request.inspect}")
end

#wait_until(description, seconds = 5, max_wait = 600, &block) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/cloud_formation/bridge/resources/base.rb', line 29

def wait_until(description, seconds = 5, max_wait = 600, &block)
  Timeout.timeout(max_wait) do
    while !block.call
      Util.logger.info("Waiting for #{description}")
      sleep(seconds)
    end
  end
end