Class: RMonitor::DSLHelpers::ProfileBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rmonitor/helpers/dsl_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProfileBuilder

Returns a new instance of ProfileBuilder.



6
7
8
# File 'lib/rmonitor/helpers/dsl_helpers.rb', line 6

def initialize
  @profiles = []
end

Instance Attribute Details

#profilesObject

Returns the value of attribute profiles.



4
5
6
# File 'lib/rmonitor/helpers/dsl_helpers.rb', line 4

def profiles
  @profiles
end

Instance Method Details

#profile(name, options = {}, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rmonitor/helpers/dsl_helpers.rb', line 10

def profile(name, options = {}, &block)
  device_builder = DeviceBuilder.new
  device_builder.instance_eval(&block)

  if options[:only_if]
    options[:only_if] = method(options[:only_if])
  elsif options[:not_if]
    options[:not_if] = method(options[:not_if])
  end

  @profiles << { :name => name,
                 :options => options,
                 :devices => device_builder.devices }
end