rails_optimizer 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rails_optimizer.rb +7 -3
- data/lib/rails_optimizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db7b90fbb9525326b32fbd31cf0a6e441e358ab6
|
4
|
+
data.tar.gz: 59e7600fd887d47e4ed0f26c469c7fcc6a0a56d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19c63413174c06fbb9e8687e0fcf449fe03e95b29a2d6bbeaccde376f0c84d55ffb4d3041dfd68448151a8444e242d1018032a447fafd82f6de1e3301d5aaf56
|
7
|
+
data.tar.gz: 4db6afa31f33630649aea0db69dbae324ed0bbf03531e2d52e923a9585a6f7235ae244c7baabf321826e1e078644e13107971f04447cb69a6cae00bd3d2f6746
|
data/Gemfile.lock
CHANGED
data/lib/rails_optimizer.rb
CHANGED
@@ -30,12 +30,16 @@ module RailsOptimizer
|
|
30
30
|
def self.belongs_to(name, scope = nil, **options)
|
31
31
|
super
|
32
32
|
define_method name.to_s do |*args|
|
33
|
-
|
34
|
-
if options[:polymorphic]
|
33
|
+
klass = if options[:polymorphic]
|
35
34
|
read_attribute("#{name}_type".to_sym).classify
|
36
35
|
else
|
37
36
|
name.to_s.classify
|
38
|
-
end
|
37
|
+
end
|
38
|
+
if args.empty?
|
39
|
+
klass.select('*').scoped(scope).finded(self, name)
|
40
|
+
else
|
41
|
+
klass.constantize.select(*args).scoped(scope).finded(self, name)
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|