Module: MuckActivities::Models::MuckActivity

Extended by:
ActiveSupport::Concern
Defined in:
lib/muck-activities/models/activity.rb

Instance Method Summary collapse

Instance Method Details

#can_edit?(check_object) ⇒ Boolean

Checks to see if the specified object can edit this activity. Most likely check_object will be a user

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
# File 'lib/muck-activities/models/activity.rb', line 52

def can_edit?(check_object)
  if check_object.is_a?(User)
    return true if check(check_object, :source_id)
  else
    source == check_object
  end
  false
end

#check_templateObject



35
36
37
# File 'lib/muck-activities/models/activity.rb', line 35

def check_template
  errors.add(:base, I18n.t('muck.activities.template_or_item_required')) if template.blank? && item.blank?
end

#has_comments?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/muck-activities/models/activity.rb', line 46

def has_comments?
  @has_comments ||= !self.comments.blank?
end

#partialObject

Provides a template that can be used to render a view of this activity. If ‘template’ is not specified when the object created then the item class name will be used to generated a template



42
43
44
# File 'lib/muck-activities/models/activity.rb', line 42

def partial
  template || item.class.name.underscore
end