has_mutex 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/init.rb +1 -0
  3. data/lib/has_mutex.rb +15 -0
  4. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f89b8d87b32d8e07b46a759ebd3fbdfdde0bf8f
4
+ data.tar.gz: 9e317a820ad029e8315343f5c829af49b7e85d4f
5
+ SHA512:
6
+ metadata.gz: 051a9259f4846ce0f5fb7472a63664c2d6b1e603ad25e1a5dd97005fb9487b3f81fb0d08da94b5c8ea08612f6fef3eeae2b54c8d5aacf69e4ddf8755ee0de872
7
+ data.tar.gz: d7caddd2f1e00993c6143a4bf2b7bb9ce8be9017b3e2f51ab6341b72ac13377a796c950aefbee5c700d92db4e9130fd9a992e184a5c96bf89e9db9a08b7a242e
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'has_mutex'
data/lib/has_mutex.rb ADDED
@@ -0,0 +1,15 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.has_mutex key = :id
4
+ @@mutex_table = {}
5
+
6
+ define_method :mutex do
7
+ @@mutex_table[read_attribute(key)] ||= Mutex.new
8
+ end
9
+ define_method :delete_mutex do
10
+ @@mutex_table.delete read_attribute(key)
11
+ end
12
+
13
+ delegate :synchronize, to: :mutex
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: has_mutex
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Michael Swan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: michael@michaelswan.io
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/has_mutex.rb
20
+ - init.rb
21
+ homepage: http://github.com/swanyboy2/has_mutex
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Creates a managable mutex table for ActiveRecord objects to access and synchronize
44
+ on.
45
+ test_files: []