Sha256: 3299f2a5d776e020d64ab4f22356472fa616c5b4907555e2a944df402af46945

Contents?: true

Size: 629 Bytes

Versions: 7

Compression:

Stored size: 629 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
    option :redis_password
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rapnd-mikec54088-0.5.5 lib/rapnd/config.rb
rapnd-mikec54088-0.5.4 lib/rapnd/config.rb
rapnd-mikec54088-0.5.3 lib/rapnd/config.rb
rapnd-mikec54088-0.5.2 lib/rapnd/config.rb
rapnd-mikec54088-0.5.1 lib/rapnd/config.rb
rapnd-mikec54088-0.5.0 lib/rapnd/config.rb
rapnd-0.5.0 lib/rapnd/config.rb