module Sneakers
  class Configuration

    extend Forwardable
    def_delegators :@hash, :to_hash, :[], :[]=, :merge!, :==

    DEFAULTS = {
      # runner
      :runner_config_file => nil,
      :metrics            => nil,
      :daemonize          => false,
      :start_worker_delay => 0.2,
      :workers            => 4,
      :log                => STDOUT,
      :pid_path           => 'sneakers.pid',

      # workers
      :timeout_job_after  => 5,
      :prefetch           => 10,
      :threads            => 10,
      :durable            => true,
      :ack                => true,
      :heartbeat          => 2,
      :exchange           => 'sneakers',
      :exchange_type      => :direct,
      :hooks              => {}
    }.freeze


    def initialize
      clear
    end

    def clear
      @hash = DEFAULTS.dup
      @hash[:amqp]  = ENV.fetch('RABBITMQ_URL', 'amqp://guest:guest@localhost:5672')
      @hash[:vhost] = AMQ::Settings.parse_amqp_url(@hash[:amqp]).fetch(:vhost, '/')
    end

    def merge(hash)
      instance = self.class.new
      instance.merge! to_hash
      instance.merge! hash
      instance
    end
  end
end
module Sneakers
  class Configuration

    extend Forwardable
    def_delegators :@hash, :to_hash, :[], :[]=, :merge!, :==, :, :fetch

    DEFAULTS = {
      # runner
      :runner_config_file => nil,
      :metrics            => nil,
      :daemonize          => false,
      :start_worker_delay => 0.2,
      :workers            => 4,
      :log                => STDOUT,
      :pid_path           => 'sneakers.pid',

      # workers
      :timeout_job_after  => 5,
      :prefetch           => 10,
      :threads            => 10,
      :durable            => true,
      :ack                => true,
      :heartbeat          => 2,
      :exchange           => 'sneakers',
      :exchange_type      => :direct,
      :hooks              => {}
    }.freeze


    def initialize
      clear
    end

    def clear
      @hash = DEFAULTS.dup
      @hash[:amqp]  = ENV.fetch('RABBITMQ_URL', 'amqp://guest:guest@localhost:5672')
      @hash[:vhost] = AMQ::Settings.parse_amqp_url(@hash[:amqp]).fetch(:vhost, '/')
    end

    def merge(hash)
      instance = self.class.new
      instance.merge! to_hash
      instance.merge! hash
      instance
    end
  end
end

Fix problem with ServerEngine::Daemon initializer
Fix problem with ServerEngine::Daemon initializer

Without this fix I get next exception:

```
rake aborted!
NoMethodError: undefined method `fetch' for #<Sneakers::Configuration:0x007fe897ed5760>
/Users/arion/.rvm/gems/ruby-1.9.3-p545/gems/serverengine-1.5.9/lib/serverengine/daemon.rb:31:in `initialize'
/Users/arion/.rvm/gems/ruby-1.9.3-p545/gems/serverengine-1.5.9/lib/serverengine.rb:50:in `new'
/Users/arion/.rvm/gems/ruby-1.9.3-p545/gems/serverengine-1.5.9/lib/serverengine.rb:50:in `create'
/Users/arion/.rvm/gems/ruby-1.9.3-p545/bundler/gems/sneakers-cf86a68e0a3a/lib/sneakers/runner.rb:11:in `run'
/Users/arion/.rvm/gems/ruby-1.9.3-p545/bundler/gems/sneakers-cf86a68e0a3a/lib/sneakers/tasks.rb:32:in `block (2 levels) in <top (required)>'
/Users/arion/.rvm/gems/ruby-1.9.3-p545/bin/ruby_noexec_wrapper:14:in `eval'
/Users/arion/.rvm/gems/ruby-1.9.3-p545/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => sneakers:run
```