Sha256: 8ba0c4c069aac338d5cf32aacf878e271b575e8fb3e7b819820cf9b74ab8c08e

Contents?: true

Size: 725 Bytes

Versions: 2

Compression:

Stored size: 725 Bytes

Contents

module Confuse
  # A {ConfigItem} is a class for storing a single piece of config. It has a
  # key, a type, a description, and a default value.
  class ConfigItem
    attr_reader :key
    attr_writer :value

    def initialize(name, &block)
      @key = name
      instance_eval(&block) unless block.nil?
    end

    def description(description = nil)
      @description = description unless description.nil?
      @description
    end

    def type(type = nil)
      @type = type unless type.nil?
      @type
    end

    def default(value = nil, &block)
      @default_value = value unless value.nil?
      @default_value = block unless block.nil?
    end

    def value
      @value || @default_value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confuse-0.1.3 lib/confuse/config_item.rb
confuse-0.1.2 lib/confuse/config_item.rb