Class: DogWatch::Model::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/dogwatch/model/options.rb

Overview

Handles the options block methods

Constant Summary collapse

MONITOR_TYPE_OPTIONS_MAP =
{
  :metric_alert => [:thresholds].freeze,
  :service_check => [:thresholds].freeze
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(monitor_type = nil) ⇒ Options

Returns a new instance of Options.

Parameters:

  • monitor_type (Symbol) (defaults to: nil)

    the monitor type of monitor these options belong to. This is used to validate monitor type specific options such as thresholds.



19
20
21
22
# File 'lib/dogwatch/model/options.rb', line 19

def initialize(monitor_type = nil)
  @attributes = OpenStruct.new
  @monitor_type = monitor_type
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



14
15
16
# File 'lib/dogwatch/model/options.rb', line 14

def attributes
  @attributes
end

Instance Method Details

#escalation_message(message) ⇒ Object

Parameters:

  • message (String)


55
56
57
# File 'lib/dogwatch/model/options.rb', line 55

def escalation_message(message)
  @attributes.escalation_message = message.to_s
end

#include_tags(include = true) ⇒ Object

Parameters:

  • include (Boolean) (defaults to: true)


65
66
67
# File 'lib/dogwatch/model/options.rb', line 65

def include_tags(include = true)
  @attributes.include_tags = !!include
end

#no_data_timeframe(minutes) ⇒ Object

Parameters:

  • minutes (Integer)


40
41
42
# File 'lib/dogwatch/model/options.rb', line 40

def no_data_timeframe(minutes)
  @attributes.no_data_timeframe = minutes.to_i
end

#notify_audit(notify = false) ⇒ Object

Parameters:

  • notify (Boolean) (defaults to: false)


60
61
62
# File 'lib/dogwatch/model/options.rb', line 60

def notify_audit(notify = false)
  @attributes.notify_audit = !!notify
end

#notify_no_data(notify = false) ⇒ Object

Parameters:

  • notify (Boolean) (defaults to: false)


35
36
37
# File 'lib/dogwatch/model/options.rb', line 35

def notify_no_data(notify = false)
  @attributes.notify_no_data = !!notify
end

#renderHash

Returns:

  • (Hash)


25
26
27
# File 'lib/dogwatch/model/options.rb', line 25

def render
  @attributes.each_pair.to_h
end

#renotify_interval(minutes) ⇒ Object

Parameters:

  • minutes (Integer)


50
51
52
# File 'lib/dogwatch/model/options.rb', line 50

def renotify_interval(minutes)
  @attributes.renotify_interval = minutes.to_i
end

#silenced(args) ⇒ Object

Parameters:

  • args (Hash)


30
31
32
# File 'lib/dogwatch/model/options.rb', line 30

def silenced(args)
  @attributes.silenced = args.to_h
end

#thresholds(thresholds) ⇒ Object

Parameters:

  • thresholds (Hash{String=>Fixnum})


70
71
72
73
# File 'lib/dogwatch/model/options.rb', line 70

def thresholds(thresholds)
  validate_monitor_type_specific_option!(:thresholds)
  @attributes.thresholds = thresholds
end

#timeout_h(hours) ⇒ Object

Parameters:

  • hours (Integer)


45
46
47
# File 'lib/dogwatch/model/options.rb', line 45

def timeout_h(hours)
  @attributes.timeout_h = hours.to_i
end