Freeze configuration defaults & duplicate in deep_merge_hashes if need be.

This commit is contained in:
Parker Moore 2016-05-18 12:48:42 -07:00 committed by Pat Hawks
parent ad59b6e62a
commit d84844c223
2 changed files with 14 additions and 1 deletions

View File

@ -72,7 +72,7 @@ module Jekyll
'hard_wrap' => false,
'footnote_nr' => 1
}
}].freeze
}.map { |k, v| [k, v.freeze] }].freeze
class << self
# Static: Produce a Configuration ready for use in a Site.

View File

@ -54,6 +54,10 @@ module Jekyll
target.default_proc = overwrite.default_proc
end
target.each do |key, val|
target[key] = val.dup if val.frozen? && duplicable?(val)
end
target
end
@ -61,6 +65,15 @@ module Jekyll
value.is_a?(Hash) || value.is_a?(Drops::Drop)
end
def duplicable?(obj)
case obj
when nil, false, true, Symbol, Numeric
false
else
true
end
end
# Read array from the supplied hash favouring the singular key
# and then the plural key, and handling any nil entries.
#