Sha256: 11d0d48efde1ccf98774e53468f50b87e0772cfdad4b0e7ce0b14f6ead5a13c1

Contents?: true

Size: 603 Bytes

Versions: 7

Compression:

Stored size: 603 Bytes

Contents

require "singleton"

module Historiographer
  class Configuration
    include Singleton

    OPTS = {
      mode: {
        default: :histories
      }
    }
    OPTS.each do |key, options|
      attr_accessor key
    end

    class << self
      def configure
        yield instance
      end

      OPTS.each do |key, options|
        define_method "#{key}=" do |value|
          instance.send("#{key}=", value)
        end

        define_method key do
          instance.send(key) || options.dig(:default)
        end
      end
    end

    def initialize
      @mode = :histories
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
historiographer-4.1.7 lib/historiographer/configuration.rb
historiographer-4.1.5 lib/historiographer/configuration.rb
historiographer-4.1.4 lib/historiographer/configuration.rb
historiographer-4.1.3 lib/historiographer/configuration.rb
historiographer-4.1.2 lib/historiographer/configuration.rb
historiographer-4.1.1 lib/historiographer/configuration.rb
historiographer-4.1.0 /Users/brettshollenberger/programming/historiographer/lib/historiographer/configuration.rb