tapioca 0.6.3 → 0.6.4

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: cc4a2a8ab8f9e4f81b9e600e00c689bc79578aa6267a9f99d44eefab1b6b6316
4
- data.tar.gz: 16c553d22afbf5bbc0fb8d366fb95e41be55f436253d7161dece29577ea7e586
3
+ metadata.gz: 6ea7bddec4d5d00918ca3236afee754f7f8dd9481d78bf8e26819c0140b154ff
4
+ data.tar.gz: 681d5ed15d27c20833aa4df86dc1a61d721e0d5993a43073873f2406a254d806
5
5
  SHA512:
6
- metadata.gz: 35ae53d442a9b2342d44f0bfe4889ed8cd59dbae526468947674a4ed1c9ceaecd84b2cedb61e997ca9b2f5481e335e61678a3be04f6f93e8f8ab14396db99030
7
- data.tar.gz: e95259f37e07b7a9de62ebdd9c620ab75f6e4e07695a757608172016948f8fc6b22b5847759f12f69eeceb56f80dacd84bc3b4dc6c1e11a09c32764d33970a4d
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.attribute_method_matchers.flat_map do |matcher|
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 handle_method_matcher?(matcher)
73
+ next unless handle_method_pattern?(pattern)
68
74
 
69
- [matcher.method_name(name), type_for(value)]
75
+ [pattern.method_name(name), type_for(value)]
70
76
  end.compact
71
77
  end
72
78
  end
73
79
 
74
- sig do
75
- params(matcher: ::ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher)
76
- .returns(T::Boolean)
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(matcher).method_missing_target
82
- else
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
- matcher.target
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
- new_method_names = constant.attribute_method_matchers.map { |m| m.method_name(attribute_name) }
118
- old_method_names = constant.attribute_method_matchers.map { |m| m.method_name(column_name) }
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)
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.6.3"
5
+ VERSION = "0.6.4"
6
6
  end
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.3
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-01-27 00:00:00.000000000 Z
14
+ date: 2022-02-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler