lib/voteable_mongo/voter.rb in voteable_mongo-0.9.1 vs lib/voteable_mongo/voter.rb in voteable_mongo-0.9.2

- old
+ new

@@ -21,11 +21,11 @@ votee = options[:votee] if votee votee_class = votee.class votee_id = votee.id else - votee_class = options[:votee_type].classify.constantize + votee_class = options[:votee_class] votee_id = options[:votee_id] end end votee_class.voted?(:voter_id => id, :votee_id => votee_id) @@ -37,13 +37,11 @@ # @return [Symbol, nil] :up or :down or nil if not voted def vote_value(options) votee = unless options.is_a?(Hash) options else - options[:votee] || options[:votee_type].classify.constantize.where( - :_id => options[:votee_id] - ).first + options[:votee] || options[:votee_class].find(options[:votee_id]) end votee.vote_value(_id) end # Cancel the vote on a votee @@ -72,11 +70,11 @@ if votee options[:votee_id] = votee.id votee_class = votee.class else - votee_class = options[:votee_type].classify.constantize + votee_class = options[:votee_class] end if options[:value].nil? options[:unvote] = true options[:value] = vote_value(options) @@ -85,10 +83,10 @@ end options[:voter] = self options[:voter_id] = id - ( votee || votee_class ).vote(options) + (votee || votee_class).vote(options) end end end end