ballot_box 0.1.2 → 0.1.3

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.
@@ -88,12 +88,13 @@ module BallotBox
88
88
  end
89
89
 
90
90
  def ballot_box_place_scope
91
- unscoped.order("#{ballot_box_cached_column} DESC")
91
+ unscoped.order("#{quoted_table_name}.#{ballot_box_cached_column} DESC")
92
92
  end
93
93
 
94
- def ballot_box_update_place!
94
+ def ballot_box_update_place!(scope = nil)
95
95
  table = quoted_table_name
96
96
  subquery = ballot_box_place_scope.select("@row := @row + 1 AS row, #{table}.id").from("#{table}, (SELECT @row := 0) r")
97
+ subquery = subquery.where(scope) if scope
97
98
 
98
99
  query = %(UPDATE #{table} AS a
99
100
  INNER JOIN (
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module BallotBox
3
- VERSION = "0.1.2".freeze
3
+ VERSION = "0.1.3".freeze
4
4
  end
@@ -21,7 +21,7 @@ module BallotBox
21
21
  validates_numericality_of :value, :only_integer => true
22
22
 
23
23
  # Callbacks
24
- before_save :parse_browser
24
+ before_create :parse_browser
25
25
  after_save :update_cached_columns
26
26
  after_destroy :update_cached_columns
27
27
 
@@ -117,9 +117,9 @@ module BallotBox
117
117
  protected
118
118
 
119
119
  def parse_browser
120
- self.browser_name = browser.id.to_s
121
- self.browser_version = browser.version
122
- self.browser_platform = browser.platform.to_s
120
+ self.browser_name ||= browser.id.to_s
121
+ self.browser_version ||= browser.version
122
+ self.browser_platform ||= browser.platform.to_s
123
123
  end
124
124
 
125
125
  def update_cached_columns
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ballot_box
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Igor Galeta
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-08 00:00:00 +03:00
19
+ date: 2011-10-07 00:00:00 +03:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency