Simplify configuration a bit, and make extensions raise an error if the user tries to set an invalid extension option.

This commit is contained in:
Ben Hollis 2013-04-12 19:55:44 -07:00
parent b9b17e3ac5
commit b607d70a52
2 changed files with 6 additions and 11 deletions

View file

@ -165,16 +165,12 @@ module Middleman
# mode and no new settings may be defined.
def finalize!
@finalized = true
self
end
# Deep duplicate of the configuration manager
def dup
copy = ConfigurationManager.new
@settings.each do |key, setting|
copy_setting = copy.define_setting(setting.key, setting.default, setting.description)
copy_setting.value = setting.value if setting.value_set?
end
copy
ConfigurationManager.new.tap {|c| c.load_settings(self.all_settings) }
end
# Load in a list of settings

View file

@ -114,15 +114,15 @@ module Middleman
attr_accessor :app, :options
def initialize(klass, options_hash={}, &block)
@options = ::Middleman::Configuration::ConfigurationManager.new
@options.load_settings(self.class.config.all_settings)
def initialize(klass, options_hash={})
@options = self.class.config.dup
@options.finalize!
options_hash.each do |k, v|
@options[k] = v
end
block.call(@options) if block_given?
yield @options if block_given?
ext = self
klass.after_configuration do
@ -132,7 +132,6 @@ module Middleman
end
def after_configuration
nil
end
end