Module MuckActivity::InstanceMethods
In: lib/muck_activities/active_record/acts/muck_activity.rb
lib/muck_activities/muck_activity.rb

Methods

Public Instance methods

add_activity adds an activity to all activites feeds that belong to the objects found in feed_to.

  • feed_to: an array of objects that have has_activities declared on them. The generated activity will be pushed into the feed of each of these objects.
  • source: the object that peformed the activity ie a user or group
  • item: an object that will be used to generated the entry in an activity feed
  • template: name of an partial that will be used to generated the entry in the activity feed. Place templates in /app/views/activity_templates
  • title: optional title that can be used in the template
  • content: option content that can be used in the template. Useful for activities that might not have
     an item but instead might have a message or other text.
    
  • check_method: method that will be called on each item in the feed_to array. If the method evaluates to false the activity won‘t be added to the object‘s activity feed. An example usage would be letting users configure which items they want to have in their activity feed.

[Source]

    # File lib/muck_activities/active_record/acts/muck_activity.rb, line 45
45:     def add_activity(feed_to, source, item, template, title = '', content = '', check_method = nil)
46:       feed_to = [feed_to] unless feed_to.is_a?(Array)
47:       activity = Activity.create(:item => item, :source => source, :template => template, :title => title, :content => content)
48:       feed_to.each do |ft|
49:         if check_method
50:           ft.activities << activity if ft.send(check_method)
51:         else
52:           ft.activities << activity
53:         end
54:       end
55:     end

add_activity adds an activity to all activites feeds that belong to the objects found in feed_to.

  • feed_to: an array of objects that have has_activities declared on them. The generated activity will be pushed into the feed of each of these objects.
  • source: the object that peformed the activity ie a user or group
  • item: an object that will be used to generated the entry in an activity feed
  • template: name of an partial that will be used to generated the entry in the activity feed. Place templates in /app/views/activity_templates
  • title: optional title that can be used in the template
  • content: option content that can be used in the template. Useful for activities that might not have
     an item but instead might have a message or other text.
    
  • check_method: method that will be called on each item in the feed_to array. If the method evaluates to false the activity won‘t be added to the object‘s activity feed. An example usage would be letting users configure which items they want to have in their activity feed.

[Source]

    # File lib/muck_activities/muck_activity.rb, line 45
45:     def add_activity(feed_to, source, item, template, title = '', content = '', check_method = nil)
46:       feed_to = [feed_to] unless feed_to.is_a?(Array)
47:       activity = Activity.create(:item => item, :source => source, :template => template, :title => title, :content => content)
48:       feed_to.each do |ft|
49:         if check_method
50:           ft.activities << activity if ft.send(check_method)
51:         else
52:           ft.activities << activity
53:         end
54:       end
55:     end

[Source]

    # File lib/muck_activities/active_record/acts/muck_activity.rb, line 63
63:     def can_view?(check_object)
64:       self == check_object
65:     end

[Source]

    # File lib/muck_activities/muck_activity.rb, line 63
63:     def can_view?(check_object)
64:       self == check_object
65:     end

status returns the first activity item from the user‘s activity feed that is a status update. Used for displaying the last status update the user made

[Source]

    # File lib/muck_activities/active_record/acts/muck_activity.rb, line 59
59:     def status
60:       self.activities.find(:first, :conditions => ['is_status_update = true'], :order => 'created_at DESC')
61:     end

status returns the first activity item from the user‘s activity feed that is a status update. Used for displaying the last status update the user made

[Source]

    # File lib/muck_activities/muck_activity.rb, line 59
59:     def status
60:       self.activities.find(:first, :conditions => ['is_status_update = true'], :order => 'created_at DESC')
61:     end

[Validate]