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. # mode and no new settings may be defined.
def finalize! def finalize!
@finalized = true @finalized = true
self
end end
# Deep duplicate of the configuration manager # Deep duplicate of the configuration manager
def dup def dup
copy = ConfigurationManager.new ConfigurationManager.new.tap {|c| c.load_settings(self.all_settings) }
@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
end end
# Load in a list of settings # Load in a list of settings

View file

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