mongoid-collection-separated 0.2.1 → 0.2.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: bbcfb28aa8720aca9c5cd1d2a1cd367edddf58be667c38c8c6339f3394f7bf31
|
4
|
+
data.tar.gz: 9b8e39fe7734198249b60e3c87d6eb8926b799d1b73f1fd785d3f1c18a1478d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f092742e2e26f1227d38e8a1d69a48bfdfde543da5e0081f167528bdd700747233aafe7d28b7274fad6f2830030e4cc249ce60740ecf66d49810f39ea63a08a
|
7
|
+
data.tar.gz: 135fe9df6a833390a2fb14d0c6e1f10d21f75e107f320a0bef156e8bd8fecab51f15a68be64e56d4c1e705ff868fa7edc730b4196e0aa5673a900b7a5ca65b24
|
@@ -8,36 +8,14 @@ module Mongoid
|
|
8
8
|
module CollectionSeparated
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
|
11
|
-
included do
|
12
|
-
action_method_module = [Mongoid::Persistable.constants.map {|c| Mongoid::Persistable.const_get(c)} + [Mongoid::Reloadable]].flatten.select {|c| c.is_a?(Module)}
|
13
|
-
action_method_module.each {|action_module| alias_method_with_collection action_module}
|
14
|
-
end
|
15
|
-
|
16
11
|
class_methods do
|
17
12
|
attr_accessor :separated_field, :separated_parent_class, :separated_parent_field, :calc_collection_name_fun
|
18
|
-
|
19
13
|
def separated_by separated_field, calc_collection_name_fun, opts={}
|
20
14
|
@separated_parent_class = opts[:parent_class].constantize
|
21
15
|
@separated_parent_field = opts[:parent_field] || :id
|
22
16
|
@separated_field = separated_field
|
23
17
|
@calc_collection_name_fun = calc_collection_name_fun
|
24
18
|
end
|
25
|
-
|
26
|
-
def alias_method_with_collection action_module
|
27
|
-
action_module.instance_methods(false).each do |action_method|
|
28
|
-
define_method "#{action_method}_with_context" do |*args|
|
29
|
-
klass = self.class
|
30
|
-
self.send "#{action_method}_without_context", *args unless klass.respond_to?(:separated_field)
|
31
|
-
|
32
|
-
collection_name = klass.where(klass.separated_field => self.send(klass.separated_field)).ensured_collection.name
|
33
|
-
self.with(collection: collection_name) {self.send "#{action_method}_without_context", *args}
|
34
|
-
end
|
35
|
-
|
36
|
-
alias_method "#{action_method}_without_context".to_sym, action_method
|
37
|
-
alias_method action_method.to_sym, "#{action_method}_with_context".to_sym
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
19
|
end
|
42
20
|
|
43
21
|
end
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
end
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_dependency 'mongoid', ' ~> 6.
|
23
|
+
spec.add_dependency 'mongoid', ' ~> 6.2'
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.17"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aibotyu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '6.
|
26
|
+
version: '6.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,7 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.7.8
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: Save the mongoid model into different collections by condition
|