Sha256: e25f81803aeec340273a2302aaf40832de2774ef8141236b90967775261d6406
Contents?: true
Size: 1.27 KB
Versions: 6
Compression:
Stored size: 1.27 KB
Contents
module SocialStream module Models # Models that have author, user_author and owner, properties saved in {Channel}. # Currently {Activity} and {ActivityObject} module Channeled extend ActiveSupport::Concern included do # Channeled models are subtypes of {Channel} # Author, owner and user_author are defined in its channel subtype_of :channel, :belongs => { :dependent => nil } before_validation :check_existing_channel end module InstanceMethods protected # Use existing channel, do not create a new one def check_existing_channel return unless channel!.new_record? existing_channel = Channel. where(:author_id => author_id, :owner_id => owner_id, :user_author_id => user_author_id). first return if existing_channel.blank? self.channel = existing_channel end end module ActiveRecord extend ActiveSupport::Concern module ClassMethods # This class is channeled. See {Channel} def channeled include SocialStream::Models::Channeled end end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems