theoooo-tally 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,9 @@ class TallySheet < ActiveRecord::Base
6
6
  validates_uniqueness_of :tallyable_id, :scope => [:tallyable_type, :voter_type, :voter_id]
7
7
  validates_inclusion_of :for, :in => [true, false]
8
8
 
9
+ after_save :update_tally_score!
10
+ after_destroy :update_tally_score!
11
+
9
12
  attr_protected :voter, :tallyable
10
13
 
11
14
  # TODO: Figure out why i can't just reference :tallyable => tallyable
@@ -18,4 +21,8 @@ class TallySheet < ActiveRecord::Base
18
21
  { :conditions => { :voter_id => voter.id, :voter_type => voter.class.to_s } }
19
22
  }
20
23
 
24
+ def update_tally_score!
25
+ self.tallyable.update_tally_score!
26
+ end
27
+
21
28
  end
@@ -14,8 +14,8 @@ class <%= migration_name %> < ActiveRecord::Migration
14
14
  add_index :tally_sheets, [ :tallyable_id, :tallyable_type ]
15
15
 
16
16
  <% tallyables.each do |t| -%>
17
- add_column :<%= t.underscore.camelize.tableize %>, :tally_sheets_count, :integer
18
- add_column :<%= t.underscore.camelize.tableize %>, :tally_score, :integer
17
+ add_column :<%= t.underscore.camelize.tableize %>, :tally_sheets_count, :integer, :default => 0
18
+ add_column :<%= t.underscore.camelize.tableize %>, :tally_score, :float, :default => 0.0
19
19
  <% end -%>
20
20
  end
21
21
 
@@ -8,7 +8,7 @@ module Tally
8
8
  module ClassMethods
9
9
  def has_tally
10
10
  include InstanceMethods
11
- has_many :votes, :as => :tallyable, :class_name => "TallySheet", :after_add => :update_tally_score!, :after_remove => :update_tally_score!
11
+ has_many :votes, :as => :tallyable, :class_name => "TallySheet"
12
12
  has_many :votes_for, :as => :tallyable, :class_name => "TallySheet", :conditions => {:for => true}
13
13
  has_many :votes_against, :as => :tallyable, :class_name => "TallySheet", :conditions => {:for => false}
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: theoooo-tally
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Cushion