eac_rails_utils 0.11.1 → 0.11.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb6393471b8d317c18c157556614ea1f40444ca56b5950998a8c51157f0101d8
|
4
|
+
data.tar.gz: b9531813f5e6283a377e0044c1b1ad1d72336701d2e2a280fa3a0ebef6ce5102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c111435248f4358873989293cc8b49826f15c01bcd78186411bb39a582c0364626ac1ec8b2ed1d4d7d2ba81b315da4eda805c13582a562a9a9881d4173ad19f4
|
7
|
+
data.tar.gz: add93d610c6303fe8687f193854af9527b48c2e31ff705bb849ccc346670055d1640d3dae4293637ac06733af73dcc1cbb7f15f7dffe9ad6562019761a4d42e8
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_model/associations/hooks'
|
4
|
+
require 'activemodel/associations'
|
5
|
+
|
6
|
+
module EacRailsUtils
|
7
|
+
module Patches
|
8
|
+
module ActiveModelAssociations
|
9
|
+
module ScopeExtensionPatch
|
10
|
+
def add_constraints(scope, owner, association_klass, *extra_args)
|
11
|
+
if extra_args.any?
|
12
|
+
refl = extra_args.first
|
13
|
+
if refl.options[:active_model]
|
14
|
+
target_ids = refl.options[:target_ids]
|
15
|
+
return scope.where(id: owner[target_ids])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module ActiveModel
|
27
|
+
module Associations
|
28
|
+
module Hooks
|
29
|
+
def self.init
|
30
|
+
ActiveSupport.on_load(:active_record) do
|
31
|
+
ActiveRecord::Associations::AssociationScope.prepend(
|
32
|
+
::EacRailsUtils::Patches::ActiveModelAssociations::ScopeExtensionPatch
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_rails_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E.A.C.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel-associations
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/eac_rails_utils/models/test_utils.rb
|
198
198
|
- lib/eac_rails_utils/patches.rb
|
199
199
|
- lib/eac_rails_utils/patches/action_controller_base.rb
|
200
|
+
- lib/eac_rails_utils/patches/active_model_associations.rb
|
200
201
|
- lib/eac_rails_utils/version.rb
|
201
202
|
- test/dummy/Rakefile
|
202
203
|
- test/dummy/app/models/job.rb
|