auto_define_scope 0.1.8 → 0.1.9
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: 40f8bf51f0ce8e65a5d61bc85f76b50e279cc437de433977ecb401bc8015de15
|
4
|
+
data.tar.gz: d97143bdeef56854418f91401c365c5808ceb7850541db53170beee22563251f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb68a6f0acfe88cbd6cc037b55e94da4a5f7b80e854f7e1d30983d4ecdcc0cfb833d0259b811cee18062a57f92f16e393583aad500900e99af03dac887c7dfa2
|
7
|
+
data.tar.gz: 28dc19bf8aa725fc28e11adeb4fb6f0a96b548990dab174c1bef10fce53f861b0a95e4e112e28a78715f29dbc483cb45342ade60a531b3a1895b244aec8d5dd4
|
@@ -46,7 +46,6 @@ module AutoDefineScope
|
|
46
46
|
next
|
47
47
|
end
|
48
48
|
column_type = klass.columns_hash[c.to_s]&.type
|
49
|
-
binding.pry if column_type
|
50
49
|
raise "scopes defined error, not found column('#{c}') for table #{klass.table_name}" if column_type.nil?
|
51
50
|
joins_params = joins_params_array.reverse.inject() { |a, n| { n => a } }
|
52
51
|
table_name = klass.table_name
|
@@ -56,11 +55,11 @@ module AutoDefineScope
|
|
56
55
|
scope scope_name, ->(v) do
|
57
56
|
value = case column_type
|
58
57
|
when :integer
|
59
|
-
|
58
|
+
v.to_i
|
60
59
|
when :string
|
61
|
-
|
60
|
+
v.to_s
|
62
61
|
else
|
63
|
-
|
62
|
+
v
|
64
63
|
end
|
65
64
|
value = type == :with ? value : "%#{value}%"
|
66
65
|
joins(joins_params).where("#{table_name}.#{c} #{OPERATE_SQL[type]}", value)
|