mongoid_token 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/mongoid/token/finders.rb +1 -0
- data/lib/version.rb +1 -1
- data/spec/mongoid/token/finders_spec.rb +18 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e7e198c4a8ca7b585adc467c61fea48a3305c09
|
4
|
+
data.tar.gz: 567b35c7a5325948819bdd451e81bc6c70ae947e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b6efae4558362e1ecd71578b754f572511f99c31aa0e130a1aaedb1102185f50acf265c5e39c8ed7a679eab0780d7d98355fb2bc87a91da7eeee989aa3c6117
|
7
|
+
data.tar.gz: 7f94095e40997135530fc3d4751033555379bda52e6dc200779823ed4f8a34466e9c9166a8def733039146926fc6f492082ae2a22f7698a633c2cb207d6d17fc
|
data/README.md
CHANGED
@@ -60,6 +60,9 @@ in your app
|
|
60
60
|
|
61
61
|
## Finders
|
62
62
|
|
63
|
+
**Note: overriding of the `find` method has been deprecated in this
|
64
|
+
version and will be removed in the next major release.**
|
65
|
+
|
63
66
|
By default, the gem will override the existing `find` method in Mongoid,
|
64
67
|
in order to search for documents based on their token first (although
|
65
68
|
the default behaviour of ObjectIDs is also there). You can disable these
|
@@ -11,6 +11,7 @@ module Mongoid
|
|
11
11
|
end
|
12
12
|
|
13
13
|
klass.define_singleton_method :"find_with_#{field_name}" do |*args| # this is going to be painful if tokens happen to look like legal object ids
|
14
|
+
warn "[DEPRECATION] Using `find' from Mongoid::Token has been deprecated and will be removed in version 3.0.0."
|
14
15
|
args.all?{|arg| BSON::ObjectId.legal?(arg)} ? send(:"find_without_#{field_name}",*args) : klass.send(:"find_by_#{field_name.to_s}", args.first)
|
15
16
|
end
|
16
17
|
|
data/lib/version.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
2
2
|
|
3
3
|
describe Mongoid::Token::Finders do
|
4
|
+
before do
|
5
|
+
@orig_stderr = $stderr
|
6
|
+
$stderr = StringIO.new
|
7
|
+
end
|
8
|
+
|
4
9
|
after do
|
10
|
+
$stderr = @orig_stderr
|
5
11
|
Object.send(:remove_const, :Document) if Object.constants.include?(:Document)
|
6
12
|
Object.send(:remove_const, :AnotherDocument) if Object.constants.include?(:AnotherDocument)
|
7
13
|
end
|
8
|
-
|
14
|
+
|
9
15
|
it "define a finder based on a field_name" do
|
10
16
|
klass = Class.new
|
11
17
|
field = :another_token
|
@@ -56,4 +62,15 @@ describe Mongoid::Token::Finders do
|
|
56
62
|
Mongoid::Token::Finders.define_custom_token_finder_for(AnotherDocument)
|
57
63
|
AnotherDocument.find(["1234", "5678"]).should == [document, document2]
|
58
64
|
end
|
65
|
+
|
66
|
+
describe :deprecations do
|
67
|
+
it "includes `find`" do
|
68
|
+
class AnotherDocument; include Mongoid::Document; field :token; end
|
69
|
+
document = AnotherDocument.create! :token => "1234"
|
70
|
+
Mongoid::Token::Finders.define_custom_token_finder_for(AnotherDocument)
|
71
|
+
AnotherDocument.find("1234")
|
72
|
+
$stderr.rewind
|
73
|
+
$stderr.string.chomp.should start_with("[DEPRECATION]"), "Expected deprecation warning for `find` method"
|
74
|
+
end
|
75
|
+
end
|
59
76
|
end
|