Class: ActionView::Helpers::AtomFeedHelper::AtomFeedBuilder
- Defined in:
- lib/action_view/helpers/atom_feed_helper.rb
Instance Method Summary collapse
-
#entry(record, options = {}) ⇒ Object
Creates an entry tag for a specific record and prefills the id using class and id.
-
#initialize(xml, view, feed_options = {}) ⇒ AtomFeedBuilder
constructor
A new instance of AtomFeedBuilder.
-
#updated(date_or_time = nil) ⇒ Object
Accepts a Date or Time object and inserts it in the proper format.
Constructor Details
#initialize(xml, view, feed_options = {}) ⇒ AtomFeedBuilder
Returns a new instance of AtomFeedBuilder.
102 103 104 |
# File 'lib/action_view/helpers/atom_feed_helper.rb', line 102 def initialize(xml, view, = {}) @xml, @view, @feed_options = xml, view, end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object (private)
137 138 139 |
# File 'lib/action_view/helpers/atom_feed_helper.rb', line 137 def method_missing(method, *arguments, &block) @xml.__send__(method, *arguments, &block) end |
Instance Method Details
#entry(record, options = {}) ⇒ Object
Creates an entry tag for a specific record and prefills the id using class and id.
Options:
-
:published
: Time first published. Defaults to the created_at attribute on the record if one such exists. -
:updated
: Time of update. Defaults to the updated_at attribute on the record if one such exists. -
:url
: The URL for this entry. Defaults to the polymorphic_url for the record.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/action_view/helpers/atom_feed_helper.rb', line 118 def entry(record, = {}) @xml.entry do @xml.id("tag:#{@view.request.host},#{@feed_options[:schema_date]}:#{record.class}/#{record.id}") if [:published] || (record.respond_to?(:created_at) && record.created_at) @xml.published(([:published] || record.created_at).xmlschema) end if [:updated] || (record.respond_to?(:updated_at) && record.updated_at) @xml.updated(([:updated] || record.updated_at).xmlschema) end @xml.link(:rel => 'alternate', :type => 'text/html', :href => [:url] || @view.polymorphic_url(record)) yield @xml end end |
#updated(date_or_time = nil) ⇒ Object
Accepts a Date or Time object and inserts it in the proper format. If nil is passed, current time in UTC is used.
107 108 109 |
# File 'lib/action_view/helpers/atom_feed_helper.rb', line 107 def updated(date_or_time = nil) @xml.updated((date_or_time || Time.now.utc).xmlschema) end |