Sha256: fc8478b02517f6e2d859bd811709ba1ef155666fa8e4daa5a5ac86a6ac9176f8

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

require 'singleton'

module Brief
  class Configuration
    include Singleton

    def self.method_missing(meth, *args, &block)
      if instance.respond_to?(meth)
        instance.send(meth, *args, &block)
      else
        super
      end
    end

    def current
      @current ||= {
        docs_path: 'docs',
        models_path: 'models',
        templates_path: 'templates',
        data_path: 'data',
        assets_path: 'assets',
        lib_path: "lib"
      }.to_mash
    end

    def set(attribute, value = nil)
      current[attribute] = value
      self
    end

    def method_missing(meth, *args, &block)
      if current.respond_to?(meth) && current.key?(meth)
        current.send(meth, *args, &block)
      else
        # swallow invalid method calls in production
        super if ENV['BRIEF_DEBUG_MODE']
        nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brief-1.15.1 lib/brief/configuration.rb
brief-1.15.0 lib/brief/configuration.rb
brief-1.14.3 lib/brief/configuration.rb