Module: Atheme::Configuration

Included in:
Atheme
Defined in:
lib/atheme/configuration.rb

Constant Summary collapse

REQUIRED_OPTIONS =
[:hostname, :port]

Instance Method Summary collapse

Instance Method Details

#configure(opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/atheme/configuration.rb', line 4

def configure(opts = {})
  unless validate_options(opts)
    raise Atheme::Error::InvalidConfiguration, "Missing configuration options: #{REQUIRED_OPTIONS.delete_if { |x| opts.has_key?(x) }.join(', ')}"
  end

  opts[:protocol] ||= 'http'

  @options = opts
end

#optionsObject



14
15
16
# File 'lib/atheme/configuration.rb', line 14

def options
  Atheme::ObjectifiedHash.new(@options)
end

#validate_options(opts) ⇒ Object



18
19
20
# File 'lib/atheme/configuration.rb', line 18

def validate_options(opts)
  REQUIRED_OPTIONS.delete_if { |x| opts.has_key?(x) }.count == 0
end