Sha256: df0c9bc56a794d5ad8a9cc2264cb2ca2299c21a5d6130bf7a73104a5627042f3

Contents?: true

Size: 811 Bytes

Versions: 17

Compression:

Stored size: 811 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'
      }.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

17 entries across 17 versions & 1 rubygems

Version Path
brief-1.9.4 lib/brief/configuration.rb
brief-1.9.3 lib/brief/configuration.rb
brief-1.9.2 lib/brief/configuration.rb
brief-1.9.1 lib/brief/configuration.rb
brief-1.9.0 lib/brief/configuration.rb
brief-1.8.12 lib/brief/configuration.rb
brief-1.8.11 lib/brief/configuration.rb
brief-1.8.10 lib/brief/configuration.rb
brief-1.8.9 lib/brief/configuration.rb
brief-1.8.8 lib/brief/configuration.rb
brief-1.8.6 lib/brief/configuration.rb
brief-1.8.5 lib/brief/configuration.rb
brief-1.8.4 lib/brief/configuration.rb
brief-1.8.3 lib/brief/configuration.rb
brief-1.8.2 lib/brief/configuration.rb
brief-1.8.1 lib/brief/configuration.rb
brief-1.8.0 lib/brief/configuration.rb