class DKIM::Query::Domain

Represents the DKIM keys of a domain.

Attributes

keys[R]

DKIM Keys of the domain

@return [Hash{String => Key}]

name[R]

Name of the domain

@return [String]

Public Class Methods

new(name,keys={}) click to toggle source

Initializes the domain.

@param [String] name

The domain name.

@param [Hash{String => Key}] keys

The DKIM Keys of the domain.

@api public

# File lib/dkim/query/domain.rb, line 36
def initialize(name,keys={})
  @name = name
  @keys = keys
end
parse(domain,keys={}) click to toggle source

Parses the DKIM Keys.

@param [String] domain

The domain the keys belong to.

@param [Hash{String => String}] keys

The DKIM selectors and keys.

@return [Domain]

The domain and it's parsed DKIM keys.

@api semipublic

# File lib/dkim/query/domain.rb, line 55
def self.parse(domain,keys={})
  keys = Hash[keys.map { |selector,record|
    [selector, Key.parse(record)]
  }]

  return new(domain,keys)
end
parse!(domain,keys={}) click to toggle source

Parses the DKIM Keys.

@param [String] domain

The domain the keys belong to.

@param [Hash{String => String}] keys

The DKIM selectors and keys.

@return [Domain]

The domain and it's parsed DKIM keys.

@raise [Parslet::ParseFailed]

One of the keys was invalid.

@api semipublic

# File lib/dkim/query/domain.rb, line 80
def self.parse!(domain,keys={})
  keys = Hash[keys.map { |selector,record|
    [selector, Key.parse!(record)]
  }]

  return new(domain,keys)
end
query(domain,options={}) click to toggle source

Queries the domain for all DKIM selectors.

@param [String] domain

The domain to query.

@option options [Array<String>] :selectors

sub-domain selectors.

@option options [Resolv::DNS] :resolver

@return [Domain]

The domain and it's DKIM Keys.

@api public

# File lib/dkim/query/domain.rb, line 104
def self.query(domain,options={})
  parse(domain,Query.query(domain,options))
end

Public Instance Methods

[](selector) click to toggle source

Selects a key from the domain.

@param [String] selector

The selector.

@return [Key, nil]

The key within that selector.
# File lib/dkim/query/domain.rb, line 135
def [](selector)
  @keys[selector]
end
each(&block) click to toggle source

Enumerates over each individual key.

@yield [key]

The given block will be passed each key.

@yieldparam [DKIM::Query::Key] key

A key belonging to the domain.

@return [Enumerator]

If no block was given, an Enumerator will be returned.

@api public

# File lib/dkim/query/domain.rb, line 122
def each(&block)
  @keys.each_value(&block)
end