contact (God)

    # File lib/god.rb, line 320
      def self.contact(kind)
        self.internal_init

        # create the contact
        begin
          c = Contact.generate(kind)
        rescue NoSuchContactError => e
          abort e.message
        end

        # send to block so config can set attributes
        yield(c) if block_given?

        # call prepare on the contact
        c.prepare

        # remove existing contacts of same name
        existing_contact = self.contacts[c.name]
        if self.running && existing_contact
          self.uncontact(existing_contact)
        end

        # warn and noop if the contact has been defined before
        if self.contacts[c.name] || self.contact_groups[c.name]
          applog(nil, :warn, "Contact name '#{c.name}' already used for a Contact or Contact Group")
          return
        end

        # abort if the Contact is invalid, the Contact will have printed
        # out its own error messages by now
        unless Contact.valid?(c) && c.valid?
          abort "Exiting on invalid contact"
        end

        # add to list of contacts
        self.contacts[c.name] = c

        # add to contact group if specified
        if c.group
          # ensure group name hasn't been used for a contact already
          if self.contacts[c.group]
            abort "Contact Group name '#{c.group}' already used for a Contact"
          end

          self.contact_groups[c.group] ||= []
          self.contact_groups[c.group] << c
        end
      end