Skip to content

Instantly share code, notes, and snippets.

@Sadin
Created September 22, 2011 15:16
Show Gist options
  • Save Sadin/1235039 to your computer and use it in GitHub Desktop.
Save Sadin/1235039 to your computer and use it in GitHub Desktop.
Example of atom feed creator
def entry(record, options = {})
@xml.entry do
@xml.id(options[:id] || "tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}")
if options[:published] || (record.respond_to?(:created_at) && record.created_at)
@xml.published((options[:published] || record.created_at).xmlschema)
end
if options[:updated] || (record.respond_to?(:updated_at) && record.updated_at)
@xml.updated((options[:updated] || record.updated_at).xmlschema)
end
@xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:url] || @view.polymorphic_url(record))
yield AtomBuilder.new(@xml)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment