mongoid-collection-separated 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dbc29dac7230c1e7ce6c9b833c61aba499cf3654bebc7c9abe016431d52b122
|
4
|
+
data.tar.gz: 29ff0b547971629f39db51654e739470386f88ececb4f4092915c0ab148717ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '068baf3c2a163607d4a05323d92c48dd18bf56318dc195b0f6289610e1bf51e8f61cfe5480c96d64bd470e495c84fe71b2e26796bbb0e3a440de0ab4cd75f00f'
|
7
|
+
data.tar.gz: afbff2f0a0a1c8c1576ab49b53f080eae68cb5e684c749ec4d046d3a01dd64b4fd9e05566f117ac313fb9c805a1f838c20ae6bd34ac156023d33beef88ae2ad0
|
@@ -1,5 +1,24 @@
|
|
1
|
+
|
2
|
+
module Mongoid
|
3
|
+
module SeparatedFun
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
def collection_name_for query_class, separated_key
|
8
|
+
cache_key = "#{__method__}_#{separated_key}"
|
9
|
+
return instance_variable_get "@#{cache_key}" if instance_variable_defined? "@#{cache_key}"
|
10
|
+
collection_name = query_class.send(query_class.calc_collection_name_fun, separated_key)
|
11
|
+
instance_variable_set "@#{cache_key}", collection_name
|
12
|
+
collection_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
1
19
|
module Mongoid
|
2
20
|
module Contextual
|
21
|
+
include Mongoid::SeparatedFun
|
3
22
|
private
|
4
23
|
|
5
24
|
# Changes:
|
@@ -21,12 +40,7 @@ module Mongoid
|
|
21
40
|
def calc_new_collection_name query_class
|
22
41
|
return unless query_class.respond_to?(:separated_field) && query_class.send(:separated_field).present?
|
23
42
|
return unless query_class.respond_to?(:calc_collection_name_fun) && query_class.respond_to?(query_class.calc_collection_name_fun)
|
24
|
-
|
25
|
-
cache_key = "#{__method__}_#{separated_key}"
|
26
|
-
return instance_variable_get "@#{cache_key}" if instance_variable_defined? "@#{cache_key}"
|
27
|
-
collection_name = query_class.send(query_class.calc_collection_name_fun, separated_key)
|
28
|
-
instance_variable_set "@#{cache_key}", collection_name
|
29
|
-
collection_name
|
43
|
+
collection_name_for query_class, separated_value(query_class)
|
30
44
|
end
|
31
45
|
|
32
46
|
def separated_value query_class
|
@@ -52,6 +66,8 @@ module Mongoid
|
|
52
66
|
module Relations
|
53
67
|
module Referenced
|
54
68
|
class Many < Relations::Many
|
69
|
+
include Mongoid::SeparatedFun
|
70
|
+
|
55
71
|
private
|
56
72
|
|
57
73
|
# Changes:
|
@@ -85,12 +101,7 @@ module Mongoid
|
|
85
101
|
end
|
86
102
|
|
87
103
|
def calc_new_collection_name query_class
|
88
|
-
|
89
|
-
cache_key = "#{__method__}_#{separated_key}"
|
90
|
-
return instance_variable_get "@#{cache_key}" if instance_variable_defined? "@#{cache_key}"
|
91
|
-
collection_name = query_class.send(query_class.calc_collection_name_fun, separated_key)
|
92
|
-
instance_variable_set "@#{cache_key}", collection_name
|
93
|
-
collection_name
|
104
|
+
collection_name_for query_class, base.send(query_class.separated_parent_field)
|
94
105
|
end
|
95
106
|
|
96
107
|
alias_method :criteria_without_separated, :criteria
|