subroutine 2.3.0 → 2.3.1
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: 0a85a75ee28c2c27b1d144059b1af01681aee27987ca2fdad9a0736b2270c824
|
4
|
+
data.tar.gz: 73bf392120764aa30da22c18b756ea8483f35b34e14e473fae6f7d495a4cbc9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea38c80c4bbf80eb1763f1052b5f0a906268b1eb6416bcd6e4f2f39a678af16395555ddc02b56867671413076680fb65343d7462974e594f112e8cdb2136f52b
|
7
|
+
data.tar.gz: b5590640ea893a227ef850fb052fb04cac6d46ccc0af2cb33b7b86972518c1b5b7988114fab0faa6472b215f8f927825c9699a08266fd6713ed8c84a88846065
|
@@ -60,7 +60,7 @@ module Subroutine
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def build_foreign_key_field
|
63
|
-
build_child_field(foreign_key_method, type: :foreign_key, foreign_key_type: determine_foreign_key_type)
|
63
|
+
build_child_field(foreign_key_method, type: :foreign_key, foreign_key_type: -> { determine_foreign_key_type })
|
64
64
|
end
|
65
65
|
|
66
66
|
def build_foreign_type_field
|
@@ -90,13 +90,15 @@ module Subroutine
|
|
90
90
|
# TODO: Make this logic work for polymorphic associations.
|
91
91
|
return if polymorphic?
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
:string
|
98
|
-
|
99
|
-
|
93
|
+
@determined_foreign_type ||= begin
|
94
|
+
klass = inferred_foreign_type&.constantize
|
95
|
+
if klass && klass.respond_to?(:type_for_attribute)
|
96
|
+
case klass.type_for_attribute(find_by)&.type&.to_sym
|
97
|
+
when :string
|
98
|
+
:string
|
99
|
+
else
|
100
|
+
:integer
|
101
|
+
end
|
100
102
|
end
|
101
103
|
end
|
102
104
|
end
|
@@ -66,6 +66,7 @@ end
|
|
66
66
|
::Subroutine::TypeCaster.register :foreign_key do |value, options = {}|
|
67
67
|
next nil if value.blank?
|
68
68
|
|
69
|
+
next ::Subroutine::TypeCaster.cast(value, type: options[:foreign_key_type].call) if options[:foreign_key_type].respond_to?(:call)
|
69
70
|
next ::Subroutine::TypeCaster.cast(value, type: options[:foreign_key_type]) if options[:foreign_key_type]
|
70
71
|
next ::Subroutine::TypeCaster.cast(value, type: :integer) if options[:name] && options[:name].to_s.end_with?("_id")
|
71
72
|
|
data/lib/subroutine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subroutine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|