Skip to content

Commit

Permalink
DRY repeated code with a private helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmaroli authored and goulvench committed Jun 24, 2020
1 parent 2246052 commit 99c5ce4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/jekyll-feed/meta-tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def attributes(collection, category)
def valid_collection
return true if generator.collections.key? @collection

Jekyll.logger.warn(
"Jekyll Feed:",
"Invalid collection name. Please review `{% feed_meta #{@args} %}`"
)
false
invalidate_with_warning("collection")
end

def valid_category
Expand All @@ -69,9 +65,13 @@ def valid_category
collection = generator.collections[@collection]
return true if collection.key?("categories") && collection["categories"].include?(@category)

invalidate_with_warning("category")
end

def invalidate_with_warning(type)
Jekyll.logger.warn(
"Jekyll Feed:",
"Invalid category name. Please review `{% feed_meta #{@args} %}`"
"Invalid #{type} name. Please review `{% feed_meta #{@args} %}`"
)
false
end
Expand Down

0 comments on commit 99c5ce4

Please sign in to comment.