Class: Eye::Dsl::ConfigOpts
- Defined in:
- lib/eye/dsl/config_opts.rb
Instance Attribute Summary
Attributes inherited from PureOpts
#config, #full_name, #name, #parent
Instance Method Summary collapse
- #contact(contact_name, contact_type, contact, contact_opts = {}) ⇒ Object
- #contact_group(contact_group_name, &block) ⇒ Object
- #set_logger(logger) ⇒ Object
Methods inherited from PureOpts
#allow_options, create_options_methods, #disallow_options, #include, #initialize, #nop, #not_seed_options, #with_condition
Constructor Details
This class inherits a constructor from Eye::Dsl::PureOpts
Instance Method Details
#contact(contact_name, contact_type, contact, contact_opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eye/dsl/config_opts.rb', line 23 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 |
#contact_group(contact_group_name, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/eye/dsl/config_opts.rb', line 37 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 |
#set_logger(logger) ⇒ Object
7 8 9 |
# File 'lib/eye/dsl/config_opts.rb', line 7 def set_logger(logger) logger.blank? ? super('') : super end |