rails_atomic_increment 0.2 → 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 170a1f8d927b96434974a14c635c765a38a350214fe0ae219166c08e0d84bfcd
4
+ data.tar.gz: 9d4f73d89248a1da7c2c9d0a1d42d5112e899d2606ac1cc80287352b95f37c64
5
+ SHA512:
6
+ metadata.gz: dfb7c9b3b0d5ee5c3de46743756dcf023a81aaf0ca1e1498c7b35cba21bfaa5567932733638c3ad214acb482ccfdfd59ded2fcae6beb1809ce3d1e774996ecdf
7
+ data.tar.gz: 4969b406babfaa8985810d3437d6c95961ccbb783814ec064024f7062e2fcca56024320e786e5e6c04407b9995adfa9129c1e847ac6b6f5d6ac809e108c26e99
@@ -0,0 +1,48 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+
9
+ jobs:
10
+ build:
11
+ name: Build + Publish
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ packages: write
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Set up Ruby 2.6
20
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
21
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
22
+ # uses: ruby/setup-ruby@v1
23
+ uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
24
+ with:
25
+ ruby-version: 2.6.10
26
+
27
+ - name: Publish to GPR
28
+ run: |
29
+ mkdir -p $HOME/.gem
30
+ touch $HOME/.gem/credentials
31
+ chmod 0600 $HOME/.gem/credentials
32
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
+ gem build *.gemspec
34
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
35
+ env:
36
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
37
+ OWNER: ${{ github.repository_owner }}
38
+
39
+ - name: Publish to RubyGems
40
+ run: |
41
+ mkdir -p $HOME/.gem
42
+ touch $HOME/.gem/credentials
43
+ chmod 0600 $HOME/.gem/credentials
44
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
45
+ gem build *.gemspec
46
+ gem push *.gem
47
+ env:
48
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/README.md CHANGED
@@ -21,5 +21,9 @@ Usage:
21
21
  user.increment_counters!([:login_attempts, :page_views]
22
22
  user.login_attempts # => 8
23
23
  user.page_views # => 1001
24
-
25
- Copyright (c) 2011 Josh Shupack
24
+
25
+ NOTE: This is designed for counters that are being updated a lot, so to decrease the DB load, the updated_at column is NOT updated when the counter get incremented. If this is an option you'd like, drop me a line and I can quickly add it for you.
26
+
27
+ It's has been tested on Rails 2.3.8 through 3.2. Recently updated for Rails 6
28
+
29
+ released under the [MIT license](http://www.opensource.org/licenses/mit-license.php) by Josh Shupack
@@ -26,7 +26,13 @@ class ActiveRecord::Base
26
26
  raise "attribute '#{attribute}' can NOT be incremented because it was already changed and that change will be lost." if !new_record? && changed_attributes[attribute.to_s]
27
27
  self[attribute] ||= 0
28
28
  self[attribute] += value
29
- @changed_attributes.delete(attribute.to_s) unless new_record? # mark this column as unchanged so it won't get updated in the DB if a save is performed on the object!
29
+ if !new_record? # mark this column as unchanged so it won't get updated in the DB if a save is performed on the object!
30
+ if @changed_attributes # Before Rails 5
31
+ @changed_attributes.delete(attribute.to_s)
32
+ else
33
+ clear_attribute_change(attribute)
34
+ end
35
+ end
30
36
  end
31
37
  if new_record?
32
38
  self.save
@@ -35,10 +41,4 @@ class ActiveRecord::Base
35
41
  end
36
42
  self.reload if reload # if we care about the new numbers in the db after the update
37
43
  end
38
-
39
- # this is for database table maintenance - May only work on MySQL? Vacuum for Postgres
40
- def self.optimize_table
41
- connection.execute("OPTIMIZE TABLE #{quoted_table_name}")
42
- end
43
-
44
- end
44
+ end
@@ -1,18 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rails_atomic_increment"
3
- s.version = "0.2"
3
+ s.version = "0.3"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ["Josh Shupack"]
6
6
  s.email = ["yNaught@gmail.com"]
7
7
  s.homepage = "http://github.com/imme5150/rails_atomic_increment"
8
8
  s.summary = "Adds atomic_increment! and atomic_decrement! to ActiveRecord models"
9
9
  s.description = "Allows you to use atomic inrement and decriment from the model instead of having to call the class. Much more object oriented"
10
- s.rubyforge_project = s.name
11
10
 
12
11
  s.required_rubygems_version = ">= 1.3.6"
13
12
 
14
13
  # If you have runtime dependencies, add them here
15
- s.add_runtime_dependency "rails", "> 2"
14
+ s.add_runtime_dependency "rails", "> 2.1"
16
15
 
17
16
  # If you have development dependencies, add them here
18
17
  # s.add_development_dependency "another", "= 0.9"
metadata CHANGED
@@ -1,44 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rails_atomic_increment
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- version: "0.2"
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.3'
9
5
  platform: ruby
10
- authors:
6
+ authors:
11
7
  - Josh Shupack
12
- autorequire:
8
+ autorequire:
13
9
  bindir: bin
14
10
  cert_chain: []
15
-
16
- date: 2011-11-22 00:00:00 -08:00
17
- default_executable:
18
- dependencies:
19
- - !ruby/object:Gem::Dependency
11
+ date: 2025-04-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
20
14
  name: rails
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
24
17
  - - ">"
25
- - !ruby/object:Gem::Version
26
- segments:
27
- - 2
28
- version: "2"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
29
20
  type: :runtime
30
- version_requirements: *id001
31
- description: Allows you to use atomic inrement and decriment from the model instead of having to call the class. Much more object oriented
32
- email:
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
27
+ description: Allows you to use atomic inrement and decriment from the model instead
28
+ of having to call the class. Much more object oriented
29
+ email:
33
30
  - yNaught@gmail.com
34
31
  executables: []
35
-
36
32
  extensions: []
37
-
38
33
  extra_rdoc_files: []
39
-
40
- files:
41
- - .gitignore
34
+ files:
35
+ - ".github/workflows/gem-push.yml"
36
+ - ".gitignore"
42
37
  - CHANGELOG.md
43
38
  - Gemfile
44
39
  - LICENSE
@@ -47,37 +42,26 @@ files:
47
42
  - lib/rails_atomic_increment.rb
48
43
  - rails_atomic_increment.gemspec
49
44
  - test/test_helper.rb
50
- has_rdoc: true
51
45
  homepage: http://github.com/imme5150/rails_atomic_increment
52
46
  licenses: []
53
-
54
- post_install_message:
47
+ metadata: {}
48
+ post_install_message:
55
49
  rdoc_options: []
56
-
57
- require_paths:
50
+ require_paths:
58
51
  - lib
59
- required_ruby_version: !ruby/object:Gem::Requirement
60
- requirements:
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
61
54
  - - ">="
62
- - !ruby/object:Gem::Version
63
- segments:
64
- - 0
65
- version: "0"
66
- required_rubygems_version: !ruby/object:Gem::Requirement
67
- requirements:
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
68
59
  - - ">="
69
- - !ruby/object:Gem::Version
70
- segments:
71
- - 1
72
- - 3
73
- - 6
60
+ - !ruby/object:Gem::Version
74
61
  version: 1.3.6
75
62
  requirements: []
76
-
77
- rubyforge_project: rails_atomic_increment
78
- rubygems_version: 1.3.6
79
- signing_key:
80
- specification_version: 3
63
+ rubygems_version: 3.2.3
64
+ signing_key:
65
+ specification_version: 4
81
66
  summary: Adds atomic_increment! and atomic_decrement! to ActiveRecord models
82
67
  test_files: []
83
-