Module: Party::Boy::ClassMethods

Defined in:
lib/party_boy.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_followableObject



17
18
19
20
21
22
23
24
25
# File 'lib/party_boy.rb', line 17

def acts_as_followable
	raise(Party::Boy::TryingTooHardError, "Can't implement both acts_as_followable and acts_as_friendly in the same class.") if self.included_modules.include?(Party::Boy::FriendlyInstanceMethods)
	with_options :class_name => 'Relationship', :dependent => :destroy do |klazz|
	 klazz.has_many :followings, :as => :requestee
	 klazz.has_many :follows, :as => :requestor
	end
	
	include Party::Boy::FollowableInstanceMethods
end

#acts_as_friendObject



27
28
29
30
31
32
33
34
35
# File 'lib/party_boy.rb', line 27

def acts_as_friend
	raise(Party::Boy::TryingTooHardError, "Can't implement both acts_as_followable and acts_as_friendly in the same class.") if self.included_modules.include?(Party::Boy::FollowableInstanceMethods)
	with_options :class_name => 'Relationship', :dependent => :destroy do |klazz|
		klazz.has_many :outgoing_friendships, :as => :requestor, :include => :requestee
		klazz.has_many :incoming_friendships, :as => :requestee, :include => :requestor
	end

	include Party::Boy::FriendlyInstanceMethods
end