tp_record_optimistic 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0dd5d0fcffaddb10783744f3eaf79d415d6858dc
4
- data.tar.gz: f2aad750e85c444a214405fe0acb050d9eb3131e
3
+ metadata.gz: 8e3a91e2f76f9fc5def099fb8a6112397ec969d0
4
+ data.tar.gz: 65c9294bc994f082bbc58e1e53eed20f39193486
5
5
  SHA512:
6
- metadata.gz: c78aa6ba5d05359ef3a8bddb85653d959f8e3257961d5d360ad11337a64e3bb21ce25e0da2c9720d7db9d97ab5df7397da697fa7b22c2ac89d23179a7a9efb7c
7
- data.tar.gz: 86ffef16fcd8e43e7dc4fc95e267e8bc3d6ce58d469801413a351b54a4a064cb42c789d370cd0957d4bce80d38bfb2c3609fad82099c8fed93c1ce8cade132e6
6
+ metadata.gz: 023f3eb1706c52918c8e5dd257d216c7f280756cf1002ba4d7d29b3da633f81a5bc6d6aa234e2b3b176f296b624b6d08f345d94c260d3b064d3643a66d048e52
7
+ data.tar.gz: 8b78f5bc293a870caeb1b9c166e3f528c7358799376e113789d76698c6a74a4536e583e4e7fca14ba82c3d9bf0132f60583c4512e1f118ebb90e7060c324d184
data/README.rdoc CHANGED
@@ -1,20 +1,33 @@
1
- = TPOptimistic
1
+ = TP optimistic lock
2
2
 
3
- This gem improve the ActiveRecord to trate ActiveRecord::RecordNotUnique with optimistic behavior
3
+ This gem extends ActiveRecord to handle ActiveRecord::RecordNotUnique with an optimistic behavior.
4
+ If a uniqueness violation is triggered by the database, it will be returned through the `errors` method.
5
+
6
+ The purpose is to be more performative and assertive than `validates_uniqueness_of`, a Rails pessimistic instruction for handling uniqueness.
7
+
8
+ `validates_uniqueness_of` performs a select query for each new insert to check unicity.
9
+ `validates_uniqueness_of` doesn't work very well in an environment with high concurrency. The select and insert are atomic operations, so some attempts of insert the same record twice happens witha high frequency.
10
+
11
+
12
+ example:
13
+ ```
14
+ class Foo < ActiveRecord::Base
15
+ acts_as_unique #
16
+ end
4
17
 
5
- exemplo:
6
18
 
7
19
  def sample
8
20
  Bar.create(uuid: '5ea880de-e4ce-4770-8d10-c89bac181e40', other: 'bla bla')
9
21
  bar = Bar.create(uuid: '5ea880de-e4ce-4770-8d10-c89bac181e40', other: 'bla bla')
10
22
 
11
- #UNIQUE constraint failed
23
+ #error returned: UNIQUE constraint failed
12
24
  bar.errors
13
25
  end
14
26
 
15
27
 
16
28
  def other_sample
17
29
  Bar.create!(uuid: '5ea880de-e4ce-4770-8d10-c89bac181e40', other: 'bla bla')
18
- #ActiveRecord::RecordInvalid UNIQUE constraint failed
30
+
31
+ #error raised: ActiveRecord::RecordInvalid UNIQUE constraint failed
19
32
  Bar.create!(uuid: '5ea880de-e4ce-4770-8d10-c89bac181e40', other: 'bla bla')
20
33
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TPRecordOptimistic
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp_record_optimistic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabricio Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2023-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -180,7 +180,7 @@ dependencies:
180
180
  version: '2.7'
181
181
  description:
182
182
  email:
183
- - fabricio.oliveira@m4u.com.br
183
+ - fabricioque@gmail.com
184
184
  executables: []
185
185
  extensions: []
186
186
  extra_rdoc_files: []
@@ -194,7 +194,7 @@ files:
194
194
  - lib/tp_record_optimistic.rb
195
195
  - lib/tp_record_optimistic/engine.rb
196
196
  - lib/tp_record_optimistic/version.rb
197
- homepage: https://github.com/fabricio-oliveira/tp_optimistic-uuid
197
+ homepage: https://github.com/fabricio-oliveira/tp_optimistic_lock
198
198
  licenses:
199
199
  - MIT
200
200
  metadata: {}
@@ -217,5 +217,5 @@ rubyforge_project:
217
217
  rubygems_version: 2.5.2
218
218
  signing_key:
219
219
  specification_version: 4
220
- summary: gem thas implement optimistic uuid
220
+ summary: gem that implement optimistic lock using unicity restriction from database
221
221
  test_files: []