class Pharrell::Environment
Public Class Methods
new()
click to toggle source
# File lib/pharrell.rb, line 36 def initialize @configs = {} @config = nil end
Public Instance Methods
config(name, opts = {}, &blk)
click to toggle source
# File lib/pharrell.rb, line 41 def config(name, opts = {}, &blk) check_options([:extends], opts) if opts[:extends] @configs[name] = fetch_config(opts[:extends]).extend(blk) else @configs[name] = Config.new(blk) end end
instance_for(klass)
click to toggle source
# File lib/pharrell.rb, line 56 def instance_for(klass) current_config.instance_for(klass) end
rebuild!()
click to toggle source
# File lib/pharrell.rb, line 60 def rebuild! current_config.rebuild! end
use_config(name)
click to toggle source
# File lib/pharrell.rb, line 51 def use_config(name) @config = name rebuild! end
Private Instance Methods
check_options(opts, opt_hash)
click to toggle source
# File lib/pharrell.rb, line 80 def check_options(opts, opt_hash) extra_keys = opt_hash.keys.reject { |key| opts.include?(key) } if extra_keys.empty? true else raise InvalidOptionsError.new(extra_keys) end end
current_config()
click to toggle source
# File lib/pharrell.rb, line 66 def current_config fetch_config(@config) end
fetch_config(name)
click to toggle source
# File lib/pharrell.rb, line 70 def fetch_config(name) config = @configs[name] if config config else raise ConfigNotDefinedError.new(name) end end