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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70068b3941cfb6ef389bf2b25f371702ef34d911
4
- data.tar.gz: 8cb79b51d9b94fb6c93da485a8c3c488f327a9ca
3
+ metadata.gz: 2e7e198c4a8ca7b585adc467c61fea48a3305c09
4
+ data.tar.gz: 567b35c7a5325948819bdd451e81bc6c70ae947e
5
5
  SHA512:
6
- metadata.gz: 9627f4505f3fbd85b499b16b04a5c2a578e480dd9033107e36549c7746a128eb6963bdc51af1eb93aaa7b2fa067d0901b2b20d7ebd0eb3343c9d788456bb063b
7
- data.tar.gz: 3c7707128f42056c1feb7b8bd1ba88a731954106a67e273e93043cefa07177c8db97deb9f0cfdbfa202c16644a9891c6791a35aadb3e719ed9375af72ea15955
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
 
@@ -1,3 +1,3 @@
1
1
  module MongoidToken
2
- VERSION = "2.1.2"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Bruning