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)


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

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

#include_tags(include = true) ⇒ Object

Parameters:

  • include (Boolean) (defaults to: true)


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

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

#no_data_timeframe(minutes) ⇒ Object

Parameters:

  • minutes (Integer)


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

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

#notify_audit(notify = false) ⇒ Object

Parameters:

  • notify (Boolean) (defaults to: false)


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

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

#notify_no_data(notify = false) ⇒ Object

Parameters:

  • notify (Boolean) (defaults to: false)


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

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

#renderObject



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

def render
  @attributes.each_pair.to_h
end

#renotify_interval(minutes) ⇒ Object

Parameters:

  • minutes (Integer)


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

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

#silenced(args) ⇒ Object

Parameters:

  • args (Hash)


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

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

#thresholds(thresholds) ⇒ Object

Parameters:

  • thresholds (Hash{String=>Fixnum})


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

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

#timeout_h(hours) ⇒ Object

Parameters:

  • hours (Integer)


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

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