mongo_mapper 0.15.6 → 0.16.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 +5 -4
- data/lib/mongo_mapper/deprecator.rb +7 -0
- data/lib/mongo_mapper/options.rb +13 -0
- data/lib/mongo_mapper/plugins/inspect.rb +4 -2
- data/lib/mongo_mapper/plugins/keys.rb +4 -2
- data/lib/mongo_mapper/plugins/strong_parameters.rb +6 -2
- data/lib/mongo_mapper/railtie.rb +12 -0
- data/lib/mongo_mapper/utils.rb +12 -0
- data/lib/mongo_mapper/version.rb +1 -1
- data/lib/mongo_mapper.rb +3 -0
- data/spec/examples.txt +1748 -1736
- data/spec/functional/embedded_document_spec.rb +33 -0
- data/spec/functional/keys_spec.rb +76 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/unit/inspect_spec.rb +50 -0
- data/spec/unit/key_spec.rb +11 -0
- data/spec/unit/mongo_mapper_spec.rb +9 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eab0f4521b6ddb6f397e27b3b299fbae43def4a8d5f7b406e18aad7da0a54b37
|
4
|
+
data.tar.gz: 27b79f11695bbf661b6cc892b151287bb90d2c551b57d40181ecceeabf10a786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd232e1e9ceb0f8c62b17a8d6287aca6d99e97fc22a07b95f423d87e89e9fc0e8a3297800292528051ee3129e96f7f134803f8fd6ad8dd6d191dbf79b8eb452e
|
7
|
+
data.tar.gz: cb0e5ce9ced8a690ae5812a576f749a6d82566c92099c8309f13d46e2a25abf5e61869f111b652576c82fee189a0d7ecfce48b8215f0965749122bb99545bb56
|
data/README.md
CHANGED
@@ -30,15 +30,16 @@ work some more on the project, send an email to Scott Taylor
|
|
30
30
|
|
31
31
|
MongoMapper is tested against:
|
32
32
|
|
33
|
-
* MRI 2.4 - 3.
|
34
|
-
* JRuby (Versions with 1
|
33
|
+
* MRI 2.4 - 3.2
|
34
|
+
* JRuby (Versions with 3.1 compatibility)
|
35
35
|
|
36
36
|
Additionally, MongoMapper is tested against:
|
37
37
|
|
38
38
|
* Rails 5.0 - 5.2
|
39
39
|
* Rails 6.0 - 6.1
|
40
|
+
* Rails 7.0 - 7.1
|
40
41
|
|
41
|
-
Note, if you are using Ruby 3.0+, you'll need Rails 6.
|
42
|
+
Note, if you are using Ruby 3.0+, you'll need Rails 6.0+.
|
42
43
|
|
43
44
|
## Contributing & Development
|
44
45
|
|
@@ -62,7 +63,7 @@ Hit up the Google group: http://groups.google.com/group/mongomapper
|
|
62
63
|
|
63
64
|
## Copyright
|
64
65
|
|
65
|
-
Copyright (c) 2009-
|
66
|
+
Copyright (c) 2009-2022 MongoMapper. See LICENSE for details.
|
66
67
|
|
67
68
|
## Contributors
|
68
69
|
|
@@ -7,10 +7,12 @@ module MongoMapper
|
|
7
7
|
def inspect(include_nil = false)
|
8
8
|
keys = include_nil ? key_names : attributes.keys
|
9
9
|
attributes_as_nice_string = keys.sort.collect do |name|
|
10
|
-
|
10
|
+
raw_value = self.send(:"#{name}").inspect
|
11
|
+
filtered_value = MongoMapper::Utils.filter_param(name, raw_value)
|
12
|
+
"#{name}: #{filtered_value}"
|
11
13
|
end.join(", ")
|
12
14
|
"#<#{self.class} #{attributes_as_nice_string}>"
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
end
|
18
|
+
end
|
@@ -442,7 +442,7 @@ module MongoMapper
|
|
442
442
|
end
|
443
443
|
|
444
444
|
def set_parent_document(key, value)
|
445
|
-
if key.type and value.
|
445
|
+
if key.type and value.kind_of?(key.type) && key.embeddable? && value.respond_to?(:_parent_document)
|
446
446
|
value._parent_document = self
|
447
447
|
end
|
448
448
|
end
|
@@ -477,7 +477,9 @@ module MongoMapper
|
|
477
477
|
def initialize_default_values(except = {})
|
478
478
|
@__mm_default_keys.each do |key|
|
479
479
|
if !(except && except.key?(key.name))
|
480
|
-
|
480
|
+
value = key.default_value
|
481
|
+
value = key.type ? key.type.to_mongo(value) : value
|
482
|
+
internal_write_key key.name, value, false
|
481
483
|
end
|
482
484
|
end
|
483
485
|
end
|
@@ -6,7 +6,11 @@ module MongoMapper
|
|
6
6
|
included do
|
7
7
|
include ::ActiveModel::ForbiddenAttributesProtection
|
8
8
|
class << self
|
9
|
-
|
9
|
+
if ::ActiveSupport.version >= Gem::Version.new("7.1")
|
10
|
+
deprecate :attr_protected, :attr_accessible, deprecator: ::MongoMapper.deprecator
|
11
|
+
else
|
12
|
+
deprecate :attr_protected, :attr_accessible
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
@@ -23,4 +27,4 @@ module MongoMapper
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
26
|
-
end
|
30
|
+
end
|
data/lib/mongo_mapper/railtie.rb
CHANGED
@@ -41,6 +41,18 @@ module MongoMapper
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
if Rails.version >= "6.0"
|
45
|
+
initializer "mongo_mapper.filter_attributes=" do |app|
|
46
|
+
ActiveSupport.on_load(:mongo_mapper) do
|
47
|
+
MongoMapper.filter_attributes += app.config.filter_parameters
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
initializer "mongo_mapper.deprecator" do |app|
|
53
|
+
app.deprecators[:mongo_mapper] = MongoMapper.deprecator if app.respond_to?(:deprecators)
|
54
|
+
end
|
55
|
+
|
44
56
|
# This sets the database configuration and establishes the connection.
|
45
57
|
initializer "mongo_mapper.initialize_database" do |app|
|
46
58
|
config_file = Rails.root.join('config/mongo.yml')
|
data/lib/mongo_mapper/utils.rb
CHANGED
@@ -8,5 +8,17 @@ module MongoMapper
|
|
8
8
|
safe = {:w => safe} if safe.is_a? Integer
|
9
9
|
safe
|
10
10
|
end
|
11
|
+
|
12
|
+
def self.filter_param(name, raw_value)
|
13
|
+
if ActiveSupport.version >= Gem::Version.new("6.0")
|
14
|
+
@filter ||= begin
|
15
|
+
require "active_support/parameter_filter"
|
16
|
+
ActiveSupport::ParameterFilter.new(MongoMapper.filter_attributes)
|
17
|
+
end
|
18
|
+
@filter.filter_param(name, raw_value)
|
19
|
+
else
|
20
|
+
raw_value
|
21
|
+
end
|
22
|
+
end
|
11
23
|
end
|
12
24
|
end
|
data/lib/mongo_mapper/version.rb
CHANGED
data/lib/mongo_mapper.rb
CHANGED
@@ -4,6 +4,7 @@ require 'active_support'
|
|
4
4
|
require 'active_support/core_ext'
|
5
5
|
require 'active_model'
|
6
6
|
require 'activemodel-serializers-xml'
|
7
|
+
require 'mongo_mapper/deprecator'
|
7
8
|
require "mongo_mapper/railtie" if defined?(Rails)
|
8
9
|
|
9
10
|
I18n.load_path << File.expand_path('../mongo_mapper/locale/en.yml', __FILE__)
|
@@ -25,6 +26,7 @@ module MongoMapper
|
|
25
26
|
autoload :Translation, 'mongo_mapper/translation'
|
26
27
|
autoload :Version, 'mongo_mapper/version'
|
27
28
|
autoload :Utils, 'mongo_mapper/utils'
|
29
|
+
autoload :Options, 'mongo_mapper/options'
|
28
30
|
|
29
31
|
module Middleware
|
30
32
|
autoload :IdentityMap, 'mongo_mapper/middleware/identity_map'
|
@@ -96,6 +98,7 @@ module MongoMapper
|
|
96
98
|
end
|
97
99
|
|
98
100
|
extend Connection
|
101
|
+
extend Options
|
99
102
|
end
|
100
103
|
|
101
104
|
Dir[File.join(File.dirname(__FILE__), 'mongo_mapper', 'extensions', '*.rb')].each do |extension|
|