Module: Recommendable::ActsAsRecommendedTo::ClassMethods

Defined in:
lib/recommendable/acts_as_recommended_to.rb

Instance Method Summary collapse

Instance Method Details



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/recommendable/acts_as_recommended_to.rb', line 13

def acts_as_recommended_to
  class_eval do
    Recommendable.user_class = self
    
    has_many :likes, :class_name => "Recommendable::Like", :dependent => :destroy
    has_many :dislikes, :class_name => "Recommendable::Dislike", :dependent => :destroy
    has_many :ignores, :class_name => "Recommendable::Ignore", :dependent => :destroy
    has_many :stashed_items, :class_name => "Recommendable::StashedItem", :dependent => :destroy
    
    include LikeMethods
    include DislikeMethods
    include StashMethods
    include IgnoreMethods
    include RecommendationMethods

    private :likes, :dislikes, :ignores, :stashed_items
  end
end

#recommends(*things) ⇒ Object



8
9
10
11
# File 'lib/recommendable/acts_as_recommended_to.rb', line 8

def recommends(*things)
  acts_as_recommended_to
  things.each { |thing| thing.to_s.classify.constantize.acts_as_recommendable }
end