Class: Eye::Dsl::ConfigOpts
Instance Attribute Summary
Attributes inherited from PureOpts
#config, #full_name, #name, #parent
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from PureOpts
#allow_options, create_options_methods, #disallow_options, #initialize, #nop, #not_seed_options, #use, #with_condition
Class Method Details
.add_notify(type) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/eye/dsl/config_opts.rb', line 18
def self.add_notify(type)
create_options_methods([type], Hash)
define_method("set_#{type}") do |value|
value = value.merge(:type => type)
super(value)
Eye::Notify.validate!(value)
end
end
|
Instance Method Details
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/eye/dsl/config_opts.rb', line 30
def contact(contact_name, contact_type, contact, contact_opts = {})
raise Eye::Dsl::Error, "unknown contact_type #{contact_type}" unless Eye::Notify::TYPES[contact_type]
raise Eye::Dsl::Error, 'contact should be a String' unless contact.is_a?(String)
notify_hash = @config[contact_type] || (@parent && @parent.config[contact_type]) || Eye::parsed_config.settings[contact_type] || {}
validate_hash = notify_hash.merge(contact_opts).merge(:type => contact_type)
Eye::Notify.validate!(validate_hash)
@config[:contacts] ||= {}
@config[:contacts][contact_name.to_s] = {name: contact_name.to_s, type: contact_type,
contact: contact, opts: contact_opts}
end
|
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/eye/dsl/config_opts.rb', line 44
def contact_group(contact_group_name, &block)
c = Eye::Dsl::ConfigOpts.new nil, self, false
c.instance_eval(&block)
cfg = c.config
@config[:contacts] ||= {}
if cfg[:contacts].present?
@config[:contacts][contact_group_name.to_s] = cfg[:contacts].values
@config[:contacts].merge!(cfg[:contacts])
end
end
|
#logger(*args) ⇒ Object
Also known as:
logger=
6
7
8
9
10
11
12
13
14
|
# File 'lib/eye/dsl/config_opts.rb', line 6
def logger(*args)
if args.empty?
@config[:logger]
else
str = args[0]
raise Eye::Dsl::Error, "logger should be a String #{str.inspect}" if !(str.is_a?(String) || str == nil)
@config[:logger] = args
end
end
|