Skip to content

Instantly share code, notes, and snippets.

@samrayner
Created April 29, 2016 10:55
Show Gist options
  • Save samrayner/9ca59a21c8d47e76c23bea0e34fd3435 to your computer and use it in GitHub Desktop.
Save samrayner/9ca59a21c8d47e76c23bea0e34fd3435 to your computer and use it in GitHub Desktop.
def default_content_for(name, content = nil, options = {}, &block)
if name.is_a? Hash
name.each { |k, v| content_for(k, v) unless content_for?(k) }
elsif content || block_given?
content_for(name, content, options, &block) unless content_for?(name)
else
raise(ArgumentError, 'expected a second argument or block for the default content')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment