Module: ThumbsUp::Karma::ClassMethods

Defined in:
lib/has_karma.rb

Instance Method Summary collapse

Instance Method Details

#has_karma(voteable_type, options = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/has_karma.rb', line 12

def has_karma(voteable_type, options = {})
  include ThumbsUp::Karma::InstanceMethods
  extend  ThumbsUp::Karma::SingletonMethods
  self.karmic_objects ||= {}
  self.karmic_objects[voteable_type.to_s.classify.constantize] = [ (options[:as] ? options[:as].to_s.foreign_key : self.name.foreign_key), [ (options[:weight] || 1) ].flatten.map(&:to_f) ]
end