mongoid-collection-separated 0.3.0 → 0.3.1

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
  SHA256:
3
- metadata.gz: c93b8ba4b2578a02d4c742f7f32da37e987a193b432c46a0940d58e25436852a
4
- data.tar.gz: b8e532c66fde7ad1a94e4a24039d666bd130727ceb48c01f1e831219c5e537e1
3
+ metadata.gz: eaeca25cec0e6b9f7eb25b233a73b0d795bb6ce6ba40e6108f87a7f9dfa80c8a
4
+ data.tar.gz: 82f28eaba1b9f99b3d40821cc2a5c05df050e457c235894b9bf53fed63cf573f
5
5
  SHA512:
6
- metadata.gz: f7f7b633a8c184b940f97fd87a70e9c03cf309a3d302360c42822fd148f37f5b97eb84d1d93675eef5ce3b975f97b172929912f83c12ef655c3cd306dad1de32
7
- data.tar.gz: cdfef2d83d9f94c0bd1930ffdcc49f0fe0e8cf685738aeb40e87cf00854e014ea174be327d2a0f24bbc1f2d38ebe2dafa6177d3c5a41d14b6bd5ecfffcdef28c
6
+ metadata.gz: 0df796bad56cb2c450ce688091b5145e188c6f32e34592a9f4988c0d466e4d74d6c9fceca50f9abb5483f1ac58ddf6a10f602c34131ac9483a9bdce27533879c
7
+ data.tar.gz: 802d77484471bcccff19959901d876caa610fd726c93823a01e0773ad4c3a68030602bdf9d9efddbd4d8832615f7425d1e9cad43d3ef255fd193d495e463f209
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  tags
14
14
  .byebug_history
15
15
  .DS_Store
16
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongoid-collection-separated (0.3.0)
4
+ mongoid-collection-separated (0.3.1)
5
5
  mongoid (~> 6.2)
6
6
 
7
7
  GEM
@@ -18,12 +18,6 @@ module Mongoid
18
18
  @calc_collection_name_fun = calc_collection_name_fun
19
19
  end
20
20
 
21
- def ensure_collection_name separate_key
22
- cache_key = "#{__method__}_#{separate_key}"
23
- return instance_variable_get "@#{cache_key}" if instance_variable_defined? "@#{cache_key}"
24
- collection_name = self.send(self.send(:calc_collection_name_fun), separate_key)
25
- instance_variable_set "@#{cache_key}", collection_name
26
- end
27
21
  end
28
22
 
29
23
  end
@@ -21,7 +21,12 @@ module Mongoid
21
21
  def calc_new_collection_name query_class
22
22
  return unless query_class.respond_to?(:separated_field) && query_class.send(:separated_field).present?
23
23
  return unless query_class.respond_to?(:calc_collection_name_fun) && query_class.respond_to?(query_class.calc_collection_name_fun)
24
- query_class.send(:ensure_collection_name, separated_value(query_class))
24
+ separated_key = separated_value(query_class)
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
25
30
  end
26
31
 
27
32
  def separated_value query_class
@@ -80,7 +85,12 @@ module Mongoid
80
85
  end
81
86
 
82
87
  def calc_new_collection_name query_class
83
- query_class.send(:ensure_collection_name, base.send(query_class.separated_parent_field))
88
+ separated_key = base.send(query_class.separated_parent_field)
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
84
94
  end
85
95
 
86
96
  alias_method :criteria_without_separated, :criteria
@@ -1,6 +1,6 @@
1
1
  module Mongoid
2
2
  module CollectionSeparated
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-collection-separated
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - aibotyu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-11 00:00:00.000000000 Z
11
+ date: 2019-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid