Class: ActionView::Helpers::AtomFeedHelper::AtomFeedBuilder

Inherits:
AtomBuilder show all
Defined in:
actionview/lib/action_view/helpers/atom_feed_helper.rb

Overview

:nodoc:

Constant Summary

Constant Summary

Constants inherited from AtomBuilder

ActionView::Helpers::AtomFeedHelper::AtomBuilder::XHTML_TAG_NAMES

Instance Method Summary (collapse)

Constructor Details

- (AtomFeedBuilder) initialize(xml, view, feed_options = {})



162
163
164
# File 'actionview/lib/action_view/helpers/atom_feed_helper.rb', line 162

def initialize(xml, view, feed_options = {})
  @xml, @view, @feed_options = xml, view, feed_options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActionView::Helpers::AtomFeedHelper::AtomBuilder

Instance Method Details

- (Object) entry(record, options = {})

Creates an entry tag for a specific record and prefills the id using class and id.

Options:



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'actionview/lib/action_view/helpers/atom_feed_helper.rb', line 180

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

    type = options.fetch(:type, 'text/html')

    @xml.link(:rel => 'alternate', :type => type, :href => options[:url] || @view.polymorphic_url(record))

    yield AtomBuilder.new(@xml)
  end
end

- (Object) updated(date_or_time = nil)

Accepts a Date or Time object and inserts it in the proper format. If nil is passed, current time in UTC is used.



167
168
169
# File 'actionview/lib/action_view/helpers/atom_feed_helper.rb', line 167

def updated(date_or_time = nil)
  @xml.updated((date_or_time || Time.now.utc).xmlschema)
end