Sha256: 5b817ff53c8ec31732dc062101e5ccb47042fcd707244502bca947dacb1fc98b
Contents?: true
Size: 1.24 KB
Versions: 6
Compression:
Stored size: 1.24 KB
Contents
### # FollowSystem module # # This module defines common behavior in follow system ### module FollowSystem ### # Followee module # # This module defines followee behavior in follow system ### module Followee ### # Extends ActiveSupport::Concern ### extend ActiveSupport::Concern ### # Included configuration ### included do ### # Has many followers association configuration ### has_many :followers, class_name: "FollowSystem::Follow", as: :followee, dependent: :destroy end ### # Specifies if self can be followed by {Follower} objects # # @return [Boolean] ### def is_followee? true end ### # Specifies if self is followed by a {Follower} object # # @param [Follower] follower - the {Follower} object to test against # @return [Boolean] ### def followed_by?(follower) Follow.follows?(follower, self) end ### # Retrieves a scope of {Follow} objects that follows self filtered {Follower} type # # @param [Class] klass - the {Class} to filter # @return [ActiveRecord::Relation] ### def followers_by(klass) Follow.scope_by_followee(self).scope_by_follower_type(klass) end end end
Version data entries
6 entries across 6 versions & 1 rubygems