Sha256: d65de867301fef007695040e08319e0fd4abeb16b03c160e4dda0d1a08edb5e1

Contents?: true

Size: 722 Bytes

Versions: 7

Compression:

Stored size: 722 Bytes

Contents

class Radiosonde::Wrapper::AlarmCollection
  include Radiosonde::Logger::Helper

  def initialize(cloud_watch, alarms, options = {})
    @cloud_watch = cloud_watch
    @alarms = alarms
    @options = options
  end

  def each
    @alarms.each do |alarm|
      yield(Radiosonde::Wrapper::Alarm.new(@cloud_watch, alarm, @options))
    end
  end

  def create(name, dsl)
    log(:info, 'Create Alarm', :cyan, name)
    opts = Radiosonde::Wrapper::Alarm.normalize_attrs(dsl)

    if @options[:dry_run]
      alarm = OpenStruct.new(opts.merge(:alarm_name => name))
    else
      alarm = @alarms.create(name, opts)
      @cloud_watch.modify!
    end

    Radiosonde::Wrapper::Alarm.new(@cloud_watch, alarm, @options)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
radiosonde-0.1.1 lib/radiosonde/wrapper/alarm_collection.rb
radiosonde-0.1.0 lib/radiosonde/wrapper/alarm_collection.rb
radiosonde-0.0.8 lib/radiosonde/wrapper/alarm_collection.rb
radiosonde-0.0.7 lib/radiosonde/wrapper/alarm_collection.rb
radiosonde-0.0.6 lib/radiosonde/wrapper/alarm_collection.rb
radiosonde-0.0.5 lib/radiosonde/wrapper/alarm_collection.rb
radiosonde-0.0.4 lib/radiosonde/wrapper/alarm_collection.rb