Sha256: 73ef822352841403b2ac660597eca2e78a5022de9d048bb59a00e4d979b80422

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 Bytes

Contents

module Stylish
  class Configuration
    include Singleton

    Defaults = {}

    def self.method_missing(meth, *args, &block)
      binding.pry

      if instance.respond_to?(meth)
        return instance.send meth, *args, &block
      end

      nil
    end

    def respond_to?(*args)
      current.send(:key?, args.first) || current.send(:respond_to?, *args)
    end

    def method_missing(meth, *args, &block)
      return current[meth] if current.key?(meth)
      super
    end

    def apply(object={})
      current.tap {|c| c.merge!(object) }
    end

    def public
      current.slice(:library_path)
    end

    def current
      @current ||= Hashie::Mash.new(Defaults).tap do |c|
        ENV.each do |key, value|
          key = key.to_s.downcase.to_sym
          c[key] = value
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stylish-0.3.1 lib/stylish/configuration.rb
stylish-0.3.0 lib/stylish/configuration.rb