Module: HasFriendship::Extender

Defined in:
lib/has_friendship/extender.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/has_friendship/extender.rb', line 3

def self.included(base)

  # Dynamically define the Friendship's association based on where the module is included.
  HasFriendship::Friendship.class_eval do
    belongs_to :friendable, polymorphic: true
    belongs_to :friend, class_name: "#{base.to_s}", foreign_key: :friend_id
  end

end