@@ -7,6 +7,8 @@ module AST
7
7
#
8
8
# @note this mixin expects `#method_name` and `#receiver` to be implemented
9
9
module MethodIdentifierPredicates # rubocop:disable Metrics/ModuleLength
10
+ extend AutoConstToSet
11
+
10
12
ENUMERATOR_METHODS = %i[ collect collect_concat detect downto each
11
13
find find_all find_index inject loop map!
12
14
map reduce reject reject! reverse_each select
@@ -75,49 +77,49 @@ def method?(name)
75
77
#
76
78
# @return [Boolean] whether the method is an operator
77
79
def operator_method?
78
- OPERATOR_METHODS . include? ( method_name )
80
+ OPERATOR_METHODS_SET . include? ( method_name )
79
81
end
80
82
81
83
# Checks whether the method is a nonmutating binary operator method.
82
84
#
83
85
# @return [Boolean] whether the method is a nonmutating binary operator method
84
86
def nonmutating_binary_operator_method?
85
- NONMUTATING_BINARY_OPERATOR_METHODS . include? ( method_name )
87
+ NONMUTATING_BINARY_OPERATOR_METHODS_SET . include? ( method_name )
86
88
end
87
89
88
90
# Checks whether the method is a nonmutating unary operator method.
89
91
#
90
92
# @return [Boolean] whether the method is a nonmutating unary operator method
91
93
def nonmutating_unary_operator_method?
92
- NONMUTATING_UNARY_OPERATOR_METHODS . include? ( method_name )
94
+ NONMUTATING_UNARY_OPERATOR_METHODS_SET . include? ( method_name )
93
95
end
94
96
95
97
# Checks whether the method is a nonmutating operator method.
96
98
#
97
99
# @return [Boolean] whether the method is a nonmutating operator method
98
100
def nonmutating_operator_method?
99
- NONMUTATING_OPERATOR_METHODS . include? ( method_name )
101
+ NONMUTATING_OPERATOR_METHODS_SET . include? ( method_name )
100
102
end
101
103
102
104
# Checks whether the method is a nonmutating Array method.
103
105
#
104
106
# @return [Boolean] whether the method is a nonmutating Array method
105
107
def nonmutating_array_method?
106
- NONMUTATING_ARRAY_METHODS . include? ( method_name )
108
+ NONMUTATING_ARRAY_METHODS_SET . include? ( method_name )
107
109
end
108
110
109
111
# Checks whether the method is a nonmutating Hash method.
110
112
#
111
113
# @return [Boolean] whether the method is a nonmutating Hash method
112
114
def nonmutating_hash_method?
113
- NONMUTATING_HASH_METHODS . include? ( method_name )
115
+ NONMUTATING_HASH_METHODS_SET . include? ( method_name )
114
116
end
115
117
116
118
# Checks whether the method is a nonmutating String method.
117
119
#
118
120
# @return [Boolean] whether the method is a nonmutating String method
119
121
def nonmutating_string_method?
120
- NONMUTATING_STRING_METHODS . include? ( method_name )
122
+ NONMUTATING_STRING_METHODS_SET . include? ( method_name )
121
123
end
122
124
123
125
# Checks whether the method is a comparison method.
@@ -138,15 +140,15 @@ def assignment_method?
138
140
#
139
141
# @return [Boolean] whether the method is an enumerator
140
142
def enumerator_method?
141
- ENUMERATOR_METHODS . include? ( method_name ) ||
143
+ ENUMERATOR_METHODS_SET . include? ( method_name ) ||
142
144
method_name . to_s . start_with? ( 'each_' )
143
145
end
144
146
145
147
# Checks whether the method is an Enumerable method.
146
148
#
147
149
# @return [Boolean] whether the method is an Enumerable method
148
150
def enumerable_method?
149
- ENUMERABLE_METHODS . include? ( method_name )
151
+ ENUMERABLE_METHODS_SET . include? ( method_name )
150
152
end
151
153
152
154
# Checks whether the method is a predicate method.
0 commit comments