tapioca 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ea7bddec4d5d00918ca3236afee754f7f8dd9481d78bf8e26819c0140b154ff
|
|
4
|
+
data.tar.gz: 681d5ed15d27c20833aa4df86dc1a61d721e0d5993a43073873f2406a254d806
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2e885fa0010d90899b1f167e3a68c1d65f7cec21d7386a321a51d753fdf6e4deaf97d5c0866b7969cf90f42a5aa68af858e173237f8fc0a7c31bc08c3931185
|
|
7
|
+
data.tar.gz: a48f142ad8402b07c2b4724801b2dee912f1b95975bb9951feb97aef433a46c248e458527827be3a450336f2c62195714a5f5b476ed7704dad4ccefdb93aca98
|
|
@@ -62,26 +62,32 @@ module Tapioca
|
|
|
62
62
|
|
|
63
63
|
sig { params(constant: ::ActiveModel::Attributes::ClassMethods).returns(T::Array[[::String, ::String]]) }
|
|
64
64
|
def attribute_methods_for(constant)
|
|
65
|
-
constant.
|
|
65
|
+
patterns = if constant.respond_to?(:attribute_method_patterns)
|
|
66
|
+
# https://github.com/rails/rails/pull/44367
|
|
67
|
+
T.unsafe(constant).attribute_method_patterns
|
|
68
|
+
else
|
|
69
|
+
constant.attribute_method_matchers
|
|
70
|
+
end
|
|
71
|
+
patterns.flat_map do |pattern|
|
|
66
72
|
constant.attribute_types.map do |name, value|
|
|
67
|
-
next unless
|
|
73
|
+
next unless handle_method_pattern?(pattern)
|
|
68
74
|
|
|
69
|
-
[
|
|
75
|
+
[pattern.method_name(name), type_for(value)]
|
|
70
76
|
end.compact
|
|
71
77
|
end
|
|
72
78
|
end
|
|
73
79
|
|
|
74
|
-
sig
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
end
|
|
78
|
-
def handle_method_matcher?(matcher)
|
|
79
|
-
target = if matcher.respond_to?(:method_missing_target)
|
|
80
|
+
sig { params(pattern: T.untyped).returns(T::Boolean) }
|
|
81
|
+
def handle_method_pattern?(pattern)
|
|
82
|
+
target = if pattern.respond_to?(:method_missing_target)
|
|
80
83
|
# Pre-Rails 6.0, the field is named "method_missing_target"
|
|
81
|
-
T.unsafe(
|
|
82
|
-
|
|
84
|
+
T.unsafe(pattern).method_missing_target
|
|
85
|
+
elsif pattern.respond_to?(:target)
|
|
83
86
|
# Rails 6.0+ has renamed the field to "target"
|
|
84
|
-
|
|
87
|
+
pattern.target
|
|
88
|
+
else
|
|
89
|
+
# https://github.com/rails/rails/pull/44367/files
|
|
90
|
+
T.unsafe(pattern).proxy_target
|
|
85
91
|
end
|
|
86
92
|
|
|
87
93
|
HANDLED_METHOD_TARGETS.include?(target.to_s)
|
|
@@ -114,8 +114,14 @@ module Tapioca
|
|
|
114
114
|
constant.attribute_aliases.each do |attribute_name, column_name|
|
|
115
115
|
attribute_name = attribute_name.to_s
|
|
116
116
|
column_name = column_name.to_s
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
patterns = if constant.respond_to?(:attribute_method_patterns)
|
|
118
|
+
# https://github.com/rails/rails/pull/44367
|
|
119
|
+
T.unsafe(constant).attribute_method_patterns
|
|
120
|
+
else
|
|
121
|
+
constant.attribute_method_matchers
|
|
122
|
+
end
|
|
123
|
+
new_method_names = patterns.map { |m| m.method_name(attribute_name) }
|
|
124
|
+
old_method_names = patterns.map { |m| m.method_name(column_name) }
|
|
119
125
|
methods_to_add = new_method_names - old_method_names
|
|
120
126
|
|
|
121
127
|
add_methods_for_attribute(mod, constant, column_name, attribute_name, methods_to_add)
|
data/lib/tapioca/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tapioca
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ufuk Kayserilioglu
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: exe
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2022-
|
|
14
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: bundler
|