mongoid-collection-separated 0.3.1 → 0.3.2

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: eaeca25cec0e6b9f7eb25b233a73b0d795bb6ce6ba40e6108f87a7f9dfa80c8a
4
- data.tar.gz: 82f28eaba1b9f99b3d40821cc2a5c05df050e457c235894b9bf53fed63cf573f
3
+ metadata.gz: 3dbc29dac7230c1e7ce6c9b833c61aba499cf3654bebc7c9abe016431d52b122
4
+ data.tar.gz: 29ff0b547971629f39db51654e739470386f88ececb4f4092915c0ab148717ba
5
5
  SHA512:
6
- metadata.gz: 0df796bad56cb2c450ce688091b5145e188c6f32e34592a9f4988c0d466e4d74d6c9fceca50f9abb5483f1ac58ddf6a10f602c34131ac9483a9bdce27533879c
7
- data.tar.gz: 802d77484471bcccff19959901d876caa610fd726c93823a01e0773ad4c3a68030602bdf9d9efddbd4d8832615f7425d1e9cad43d3ef255fd193d495e463f209
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
- 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
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
- 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
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
@@ -1,6 +1,6 @@
1
1
  module Mongoid
2
2
  module CollectionSeparated
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-collection-separated
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - aibotyu