rails_optimizer 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +1 -1
- data/lib/rails_optimizer/association.rb +5 -0
- data/lib/rails_optimizer/belongs_to.rb +9 -7
- data/lib/rails_optimizer/has_one.rb +7 -13
- data/lib/rails_optimizer/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2a70969d26fb8c6f7e10d076d0d773a85f8c196c09e56494c5cc7707a6861222
|
4
|
+
data.tar.gz: 7a3d74687e69d53d289582128bf14e1092467ecaafa094a29add6c7cfcaab1a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd2be7a17816296ad15d5677c25b701abf437f77df5046e14182a96916e90931d668cbfa1759e55cd2bb972c4b4811dd914c912462f0f8ea43a05785dae81b84
|
7
|
+
data.tar.gz: 82c0eae0f03d3d14cddc0f57e592be30a0bb05be5ca2b81d1d3269f0dac4528f39beecd2db4c49808403874f326bc5612d3eec5eefff03bb6483140022a80b51
|
data/Gemfile.lock
CHANGED
@@ -8,20 +8,22 @@ module RailsOptimizer
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def get_target
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
super do
|
12
|
+
if args.empty?
|
13
|
+
klass
|
14
|
+
else
|
15
|
+
klass.select(*args)
|
16
|
+
end
|
17
|
+
.execute(&reflection_scope)
|
18
|
+
.execute(&finded)
|
15
19
|
end
|
16
|
-
.execute(&reflection_scope)
|
17
|
-
.execute(&finded)
|
18
20
|
end
|
19
21
|
|
20
22
|
private
|
21
23
|
|
22
24
|
def finded
|
23
25
|
id = owner.read_attribute(foreign_key)
|
24
|
-
proc { send(:
|
26
|
+
proc { send(:find_by, {id: id}) }
|
25
27
|
end
|
26
28
|
|
27
29
|
def foreign_key
|
@@ -9,11 +9,13 @@ module RailsOptimizer
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def get_target
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
super do
|
13
|
+
if args.empty?
|
14
|
+
klass
|
15
|
+
else
|
16
|
+
klass.select(*args)
|
17
|
+
end.execute(&reflection_scope).execute(&finded)
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
@@ -24,12 +26,4 @@ module RailsOptimizer
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
define_method name.to_s do |*args|
|
28
|
-
fk = self.class.foreign_key(name).to_sym
|
29
|
-
if args.empty?
|
30
|
-
name.to_s.classify.constantize.select("*").scoped(scope).find_by(fk => id)
|
31
|
-
else
|
32
|
-
name.to_s.classify.constantize.select(:id, *args).scoped(scope).find_by(fk => id)
|
33
|
-
end
|
34
|
-
end
|
35
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_optimizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facundo A. Díaz Martínez
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -70,7 +70,7 @@ metadata:
|
|
70
70
|
allowed_push_host: https://rubygems.org
|
71
71
|
homepage_uri: https://github.com/ITSesocio/rails_optimizer
|
72
72
|
source_code_uri: https://github.com/ITSesocio/rails_optimizer
|
73
|
-
post_install_message:
|
73
|
+
post_install_message:
|
74
74
|
rdoc_options: []
|
75
75
|
require_paths:
|
76
76
|
- lib
|
@@ -85,9 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
|
89
|
-
|
90
|
-
signing_key:
|
88
|
+
rubygems_version: 3.0.3
|
89
|
+
signing_key:
|
91
90
|
specification_version: 4
|
92
91
|
summary: Optimze some rails methods
|
93
92
|
test_files: []
|