Sha256: 18aed9fe9cc4f9dc131e97877bf4af0790f7f0e0d3c12a7f8d19f33aeb23ad24
Contents?: true
Size: 962 Bytes
Versions: 6
Compression:
Stored size: 962 Bytes
Contents
module Mina class Configuration include Singleton include Helpers::Internal module DSL def self.included(base) [:set, :fetch, :remove, :set?, :ensure!, :reset!].each do |method| base.send :define_method, method do |*args, &block| Configuration.instance.send(method, *args, &block) end end end end attr_reader :variables def initialize @variables ||= {} end def set(key, value = nil, &block) variables[key] = block || value end def fetch(key, default = nil) value = ENV[key.to_s] || variables.fetch(key, default) value.respond_to?(:call) ? value.call : value end def remove(key) variables.delete(key) end def set?(key) !variables.fetch(key, nil).nil? end def ensure!(key) error! "#{key} must be defined!" unless set?(key) end def reset! @variables = {} end end end
Version data entries
6 entries across 6 versions & 1 rubygems