theoooo-tally 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tally/voter.rb +2 -6
- metadata +1 -1
data/lib/tally/voter.rb
CHANGED
@@ -25,28 +25,24 @@ module Tally
|
|
25
25
|
|
26
26
|
def vote tallyable, value
|
27
27
|
# TODO: Figure out why i can't just reference :tallyable => tallyable
|
28
|
-
votes.tally(tallyable).find(:first).try(:update_attribute, :for,
|
29
|
-
votes.create(:tallyable_id => tallyable.id, :tallyable_type => tallyable.class.to_s, :for =>
|
28
|
+
votes.tally(tallyable).find(:first).try(:update_attribute, :for, value) ||
|
29
|
+
votes.create(:tallyable_id => tallyable.id, :tallyable_type => tallyable.class.to_s, :for => value)
|
30
30
|
end
|
31
31
|
|
32
32
|
def vote_destroy tallyable
|
33
33
|
votes.tally(tallyable).find(:first).try(:destroy)
|
34
|
-
# votes.find(:first, :conditions => {:tallyable => tallyable}).try(:destroy)
|
35
34
|
end
|
36
35
|
|
37
36
|
def voted_for? tallyable
|
38
37
|
!!votes.tally(tallyable).find(:first, :conditions => {:for => true})
|
39
|
-
# !!votes.find(:first, :conditions => {:tallyable => tallyable, :for => true})
|
40
38
|
end
|
41
39
|
|
42
40
|
def voted_against? tallyable
|
43
41
|
!!votes.tally(tallyable).find(:first, :conditions => {:for => false})
|
44
|
-
# !!votes.find(:first, :conditions => {:tallyable => tallyable, :for => false})
|
45
42
|
end
|
46
43
|
|
47
44
|
def voted_on? tallyable
|
48
45
|
!!votes.tally(tallyable).find(:first)
|
49
|
-
# !!votes.find(:first, :conditions => {:tallyable => tallyable})
|
50
46
|
end
|
51
47
|
|
52
48
|
end
|