Sha256: d45075a8e62d2fa227c608ad317e6fab2c1374957e07f6e0bb8193e321b7c4b9

Contents?: true

Size: 602 Bytes

Versions: 4

Compression:

Stored size: 602 Bytes

Contents

module Rapnd
  module Config
    extend self
    
    def option(name, options = {})
      defaults[name] = settings[name] = options[:default]

      class_eval <<-RUBY
        def #{name}
          settings[#{name.inspect}]
        end

        def #{name}=(value)
          settings[#{name.inspect}] = value
        end

        def #{name}?
          #{name}
        end
      RUBY
    end
    
    def defaults
      @defaults ||= {}
    end
    
    def settings
      @settings ||= {}
    end
    
    option :redis_host, :default => 'localhost'
    option :redis_port, :default => 6879
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rapnd-0.4.1 lib/rapnd/config.rb
rapnd-0.4.0 lib/rapnd/config.rb
rapnd-0.3.1 lib/rapnd/config.rb
rapnd-0.3.0 lib/rapnd/config.rb