Module: Interest::Followable::Follower::ClassMethods
- Defined in:
- lib/interest/followable/follower.rb
Instance Method Summary collapse
- #define_follower_association_method(source_type) ⇒ Object
- #define_follower_association_methods ⇒ Object
Instance Method Details
#define_follower_association_method(source_type) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/interest/followable/follower.rb', line 56 def define_follower_association_method(source_type) association_method_name = follower_association_method_name_for source_type has_many association_method_name, -> { uniq }, through: :following_relationships, source: :followee, source_type: source_type end |
#define_follower_association_methods ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/interest/followable/follower.rb', line 46 def define_follower_association_methods has_many :following_relationships, -> { where(Interest.following_class.table_name.to_sym => {status: "accepted"}).uniq }, as: :follower, dependent: :destroy, class_name: Interest.following_class_name do include Interest::Definition.collection_methods_for(:followee) end end |