diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index 98eb864a..23237a08 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -83,6 +83,19 @@ module Jekyll end end + # Check if key exists in Drop + # + # key - the string key whose value to fetch + # + # Returns true if the given key is present + def key?(key) + if self.class.mutable && @mutations.key?(key) + true + else + respond_to?(key) || fallback_data.key?(key) + end + end + # Generates a list of keys with user content as their values. # This gathers up the Drop methods and keys of the mutations and # underlying data hashes and performs a set union to ensure a list diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 673d9a99..edf70969 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -90,7 +90,7 @@ module Jekyll end def applies_path?(scope, path) - return true if !scope.has_key?('path') || scope['path'].empty? + return true if !scope.key?('path') || scope['path'].empty? scope_path = Pathname.new(scope['path']) Pathname.new(sanitize_path(path)).ascend do |path| @@ -150,7 +150,7 @@ module Jekyll # Returns an array of hashes def matching_sets(path, type) valid_sets.select do |set| - !set.has_key?('scope') || applies?(set['scope'], path, type) + !set.key?('scope') || applies?(set['scope'], path, type) end end diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index c7d47c59..52ff5178 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -90,7 +90,7 @@ module Jekyll return true if path.nil? # Check for path in cache - if cache.has_key? path + if cache.key? path return cache[path] end diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index e3bee115..4152e7ef 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -115,7 +115,7 @@ eos validate_path(path, dir, site.safe) # Add include to dependency tree - if context.registers[:page] && context.registers[:page].has_key?("path") + if context.registers[:page] && context.registers[:page].key?("path") site.regenerator.add_dependency( site.in_source_dir(context.registers[:page]["path"]), path @@ -138,7 +138,7 @@ eos context.registers[:cached_partials] ||= {} cached_partial = context.registers[:cached_partials] - if cached_partial.has_key?(path) + if cached_partial.key?(path) cached_partial[path] else cached_partial[path] = context.registers[:site].liquid_renderer.file(path).parse(read_file(path, context))