Class: Radiosonde::Wrapper::AlarmCollection

Inherits:
Object
  • Object
show all
Includes:
Logger::Helper
Defined in:
lib/radiosonde/wrapper/alarm_collection.rb

Instance Method Summary collapse

Methods included from Logger::Helper

#log

Constructor Details

#initialize(cloud_watch, alarms, options = {}) ⇒ AlarmCollection

Returns a new instance of AlarmCollection.



4
5
6
7
8
# File 'lib/radiosonde/wrapper/alarm_collection.rb', line 4

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

Instance Method Details

#create(name, dsl) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/radiosonde/wrapper/alarm_collection.rb', line 16

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

#eachObject



10
11
12
13
14
# File 'lib/radiosonde/wrapper/alarm_collection.rb', line 10

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