lib/tapioca/dsl/compilers/active_model_attributes.rb in tapioca-0.9.4 vs lib/tapioca/dsl/compilers/active_model_attributes.rb in tapioca-0.10.0

- old
+ new

@@ -51,13 +51,17 @@ generate_method(klass, method, attribute_type) end end end - sig { override.returns(T::Enumerable[Module]) } - def self.gather_constants - all_classes.grep(::ActiveModel::Attributes::ClassMethods) + class << self + extend T::Sig + + sig { override.returns(T::Enumerable[Module]) } + def gather_constants + all_classes.grep(::ActiveModel::Attributes::ClassMethods) + end end private HANDLED_METHOD_TARGETS = T.let(["attribute", "attribute="], T::Array[String]) @@ -69,14 +73,14 @@ T.unsafe(constant).attribute_method_patterns else constant.attribute_method_matchers end patterns.flat_map do |pattern| - constant.attribute_types.map do |name, value| + constant.attribute_types.filter_map do |name, value| next unless handle_method_pattern?(pattern) [pattern.method_name(name), type_for(value)] - end.compact + end end end sig { params(pattern: T.untyped).returns(T::Boolean) } def handle_method_pattern?(pattern)