Sha256: baca85d78a2e779ce092eab52cb15d9b95d3ba58879f2969693453407f3d7309
Contents?: true
Size: 829 Bytes
Versions: 4
Compression:
Stored size: 829 Bytes
Contents
# Convenience class for managing like activities class Like attr_reader :activity class << self # Find the children activity of activity_id liked by subject def find(subject, activity_id) find_activity(activity_id).liked_by(subject).first end # Like #find but raises error if not found def find!(subject, activity_id) find(subject, activity_id) || raise(ActiveRecord::RecordNotFound) end # Find the activity that is liked def find_activity(id) Activity.find(id) || raise(ActiveRecord::RecordNotFound) end end # Initialize a new like activity def initialize(subject, activity_id) @subject = subject @activity = self.class.find_activity(activity_id) @like = @activity.new_like(@subject) end def save @like.save end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
social_stream-0.4.3 | app/models/like.rb |
social_stream-0.4.2 | app/models/like.rb |
social_stream-0.4.1 | app/models/like.rb |
social_stream-0.4.0 | app/models/like.rb |