module Interferon::DSLMixin
Public Class Methods
new(hostinfo)
click to toggle source
# File lib/interferon/alert_dsl.rb, line 5 def initialize(hostinfo) @hostinfo = hostinfo end
Public Instance Methods
[](arg)
click to toggle source
# File lib/interferon/alert_dsl.rb, line 13 def [](arg) send(arg) end
method_missing(meth, *_args)
click to toggle source
# File lib/interferon/alert_dsl.rb, line 9 def method_missing(meth, *_args) raise ArgumentError, "No such alerts field '#{meth}'" end
Private Instance Methods
get_or_set(field, val, block, default) { |f| ... }
click to toggle source
# File lib/interferon/alert_dsl.rb, line 19 def get_or_set(field, val, block, default) if val.nil? && block.nil? f = instance_variable_get(field) f.nil? ? default : f elsif !val.nil? && !block.nil? raise ArgumentError, "You must pass either a value or a block but not both to #{field}" else f = val.nil? ? block.call : val f = yield(f) if block_given? instance_variable_set(field, f) end end