mongoid-locker 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1 ([diff](https://github.com/afeld/mongoid-locker/compare/v0.1.0...v0.1.1?w=1))
4
+
5
+ * fix for subclasses - #5
6
+
7
+ ## 0.1.0
8
+
9
+ Initial release!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -27,7 +27,8 @@ module Mongoid
27
27
  #
28
28
  # @return [Fixnum] the default number of seconds until a lock is considered "expired", in seconds
29
29
  def lock_timeout
30
- @lock_timeout
30
+ # default timeout of five seconds
31
+ @lock_timeout || 5
31
32
  end
32
33
  end
33
34
 
@@ -37,9 +38,6 @@ module Mongoid
37
38
 
38
39
  mod.field :locked_at, :type => Time
39
40
  mod.field :locked_until, :type => Time
40
-
41
- # default timeout of five seconds
42
- mod.instance_variable_set :@lock_timeout, 5
43
41
  end
44
42
 
45
43
 
@@ -47,7 +45,7 @@ module Mongoid
47
45
  #
48
46
  # @return [Boolean] true if locked, false otherwise
49
47
  def locked?
50
- self.locked_until && self.locked_until > Time.now
48
+ !!(self.locked_until && self.locked_until > Time.now)
51
49
  end
52
50
 
53
51
  # Primary method of plugin: execute the provided code once the document has been successfully locked.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mongoid-locker"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aidan Feldman"]
12
- s.date = "2012-07-03"
12
+ s.date = "2012-07-11"
13
13
  s.description = "Allows multiple processes to operate on individual documents in MongoDB while ensuring that only one can act at a time."
14
14
  s.email = "aidan.feldman@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  ".document",
21
21
  ".rspec",
22
22
  ".travis.yml",
23
+ "CHANGELOG.md",
23
24
  "Gemfile",
24
25
  "Guardfile",
25
26
  "LICENSE.txt",
@@ -103,6 +103,23 @@ describe Mongoid::Locker do
103
103
  @user.locked_until.to_i.should eq(expiration)
104
104
  end
105
105
  end
106
+
107
+ it "should succeed for subclasses" do
108
+ class Admin < User
109
+ end
110
+
111
+ admin = Admin.create!
112
+
113
+ admin.with_lock do
114
+ admin.should be_locked
115
+ Admin.first.should be_locked
116
+ end
117
+
118
+ admin.should_not be_locked
119
+ admin.reload.should_not be_locked
120
+
121
+ remove_class Admin
122
+ end
106
123
  end
107
124
 
108
125
  describe ".timeout_lock_after" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-locker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-03 00:00:00.000000000 Z
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -119,6 +119,7 @@ files:
119
119
  - .document
120
120
  - .rspec
121
121
  - .travis.yml
122
+ - CHANGELOG.md
122
123
  - Gemfile
123
124
  - Guardfile
124
125
  - LICENSE.txt
@@ -146,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
147
  version: '0'
147
148
  segments:
148
149
  - 0
149
- hash: 2896270749272846608
150
+ hash: 1869316857969046476
150
151
  required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  none: false
152
153
  requirements: