Skip to content

Instantly share code, notes, and snippets.

@denisdefreyne
Last active December 17, 2015 15:09
Show Gist options
  • Save denisdefreyne/5630100 to your computer and use it in GitHub Desktop.
Save denisdefreyne/5630100 to your computer and use it in GitHub Desktop.
module Nanoc
class ContentPiece
def initialize(content, attributes, identifier)
# Content
if content.nil?
raise ArgumentError, "attempted to create a #{self.class} with no content/filename (identifier #{@identifier})"
elsif content.is_a?(Nanoc::TextualContent)
@content = content
else
@content = Nanoc::TextualContent.new(content.to_s, nil)
end
# Attributes
@attributes = attributes.symbolize_keys_recursively
# Identifier
if identifier.is_a?(Nanoc::Identifier)
@identifier = identifier
else
@identifier = Nanoc::Identifier.from_string(identifier.to_s)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment