Skip to content

Commit 00a16c0

Browse files
committed
Fix resolving mixins that mix themselves in
1 parent e167846 commit 00a16c0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

lib/yard/handlers/ruby/mixin_handler.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ def process_mixin(mixin)
2626
raise YARD::Parser::UndocumentableError unless mixin.ref?
2727
raise YARD::Parser::UndocumentableError if mixin.first.type == :ident
2828

29-
case obj = Proxy.new(namespace, mixin.source)
30-
when ConstantObject # If a constant is included, use its value as the real object
31-
obj = Proxy.new(namespace, obj.value, :module)
29+
if mixin.source == "self"
30+
obj = namespace
3231
else
33-
obj = Proxy.new(namespace, mixin.source, :module)
32+
case obj = Proxy.new(namespace, mixin.source)
33+
when ConstantObject # If a constant is included, use its value as the real object
34+
obj = Proxy.new(namespace, obj.value, :module)
35+
else
36+
obj = Proxy.new(namespace, mixin.source, :module)
37+
end
3438
end
3539

3640
rec = recipient(mixin)

spec/handlers/examples/mixin_handler_001.rb.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ end
3838

3939
module FromConstant; end
4040
FromConstant.include A
41+
42+
module Foo
43+
end
44+
45+
module MixMySelfIn
46+
Foo.include(self)
47+
end

spec/handlers/mixin_handler_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ class D1; class E1; class F1; end end end
6969
expect(YARD::Registry.root.instance_mixins).not_to eq [P('D1::E1::F1')]
7070
expect(P('A1::B1::C1').instance_mixins).to eq [P('D1::E1::F1')]
7171
end
72+
73+
it "resolves modules that mix themselves in" do
74+
expect(Registry.at('Foo').mixins).to eq [P('MixMySelfIn')]
75+
end
7276
end

0 commit comments

Comments
 (0)