Module: Espresso::Controller::InheritedResourcesModifications::ClassMethods

Defined in:
lib/espresso/controller/inherited_resources.rb

Instance Method Summary collapse

Instance Method Details

#has_feed(*args) ⇒ Object

Adds ability to build feeds for resource’s collections. By default adds Atom feed

Examples:

Add Atom feed for #index

has_feed :atom

Add Atom and RSS feed for #index

has_feed :atom, :rss

Add Atom, Rss, and ITunes feed for #index, #list and #archive

has_feed :atom, :rss, :itunesfeed, :only => [:index, :list, :archive]


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/espresso/controller/inherited_resources.rb', line 63

def has_feed(*args)
  require 'has_scope'

  options = args.extract_options!
  if options.empty?
    options[:only] = :index
  end

  class_inheritable_accessor(:feed_formats) unless respond_to?(:feed_formats)
  self.feed_formats = (args.empty? ? [:atom] : args).map(&:to_s)

  self.feed_formats.each do |format|
    respond_to format, options
  end

  include FeedScope
  has_scope(:for_feed, options.merge(:default => true,
                                     :type => :boolean,
                                     :if => :feed_scope_applicable?))
end