Skip to content

Commit d0d5414

Browse files
committed
Use Class#subclasses
1 parent 3f2a59c commit d0d5414

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lib/dry/struct/class_interface.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ module ClassInterface # rubocop:disable Metrics/ModuleLength
1111
include Types::Type
1212
include Types::Builder
1313

14-
# @param [Class] klass
15-
def inherited(klass)
16-
super
17-
18-
unless klass.name.eql?("Dry::Struct::Value")
19-
klass.extend(Core::DescendantsTracker)
20-
end
21-
end
22-
2314
# Adds an attribute for this {Struct} with given `name` and `type`
2415
# and modifies {.schema} accordingly.
2516
#
@@ -189,8 +180,7 @@ def attributes(new_schema)
189180

190181
@attribute_names = nil
191182

192-
direct_descendants = descendants.select { |d| d.superclass == self }
193-
direct_descendants.each do |d|
183+
subclasses.each do |d|
194184
inherited_attrs = new_schema.reject { |k, _| d.has_attribute?(k.to_s.chomp("?").to_sym) }
195185
d.attributes(inherited_attrs)
196186
end

0 commit comments

Comments
 (0)