Module: Interest::Followable::Followee::ClassMethods

Defined in:
lib/interest/followable/followee.rb

Instance Method Summary collapse

Instance Method Details

#define_followee_association_method(source_type) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/interest/followable/followee.rb', line 29

def define_followee_association_method(source_type)
  association_method_name = followee_association_method_name_for source_type

  has_many association_method_name,
    through:     :follower_relationships,
    source:      :follower,
    source_type: source_type
end

#define_followee_association_methodsObject



19
20
21
22
23
24
25
26
27
# File 'lib/interest/followable/followee.rb', line 19

def define_followee_association_methods
  has_many :follower_relationships,
    -> { where(Interest.following_class.table_name.to_sym => {status: "accepted"}) },
    as:          :followee,
    dependent:   :destroy,
    class_name:  Interest.following_class_name do
      include Interest::Definition.collection_methods_for(:follower)
    end
end