Class: FeedItem

Inherits:
Object
  • Object
show all
Defined in:
app/models/feed_item.rb

Overview

FeedItems are used to represent RSS atom items Used e.g. in HomeController as

    FeedItem.new( ("%s %% %s" % [posting.title,comment.name]),
                  comment.comment,
                  comment.updated_at,
                  posting_url(posting),comment)

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (FeedItem) initialize(title, body, updated_at, url, object)

A new instance of FeedItem

Parameters:

  • title (String)

    the title used for the rss-item

  • body: (String)

    the rss-item-body

  • updated_at: (Time)
  • Object (Object)

    any object. Appreciate if responds to :name.



17
18
19
# File 'app/models/feed_item.rb', line 17

def initialize(title, body, updated_at, url, object)
  @title,@body,@updated_at,@url,@object = title, body, updated_at, url, object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method_sym, *arguments, &block)

If the user calls any method we try to delegate to our @object

Parameters:

  • method_sym (Symbol)

    Method to call

  • arguments (Array)

    Arguments to pass to the call.



34
35
36
# File 'app/models/feed_item.rb', line 34

def method_missing(method_sym, *arguments, &block)
  object.send(method_sym,*arguments)
end

Instance Attribute Details

- (Object) body (readonly)

Returns the value of attribute body



11
12
13
# File 'app/models/feed_item.rb', line 11

def body
  @body
end

- (Object) object (readonly)

Returns the value of attribute object



11
12
13
# File 'app/models/feed_item.rb', line 11

def object
  @object
end

- (Object) title (readonly)

Returns the value of attribute title



11
12
13
# File 'app/models/feed_item.rb', line 11

def title
  @title
end

- (Object) updated_at (readonly)

Returns the value of attribute updated_at



11
12
13
# File 'app/models/feed_item.rb', line 11

def updated_at
  @updated_at
end

- (Object) url (readonly)

Returns the value of attribute url



11
12
13
# File 'app/models/feed_item.rb', line 11

def url
  @url
end

Instance Method Details

- (Object) name

The name of the object if object respond to :name or the application name as configured otherwise.



23
24
25
26
27
28
29
# File 'app/models/feed_item.rb', line 23

def name
  if object.respond_to?(:name) && object.name !~ /anonymous|anonym/
    object.name
  else
    APPLICATION_CONFIG[:name]
  end
end