Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure that defaults are inherited from parent class

  • Loading branch information...
commit 67f5351fb4eed617e39cbd91b4718f6926b6fb4e 1 parent 96c1f0d
@lsegal authored
Showing with 12 additions and 1 deletion.
  1. +1 −1  lib/yard/options.rb
  2. +11 −0 spec/options_spec.rb
View
2  lib/yard/options.rb
@@ -188,7 +188,7 @@ def reset_defaults
names_set = {}
self.class.ancestors.each do |klass| # look at all ancestors
defaults = klass.instance_variable_get("@defaults")
- return unless defaults
+ next unless defaults
defaults.each do |key, value|
next if names_set[key]
names_set[key] = true
View
11 spec/options_spec.rb
@@ -36,6 +36,17 @@ class ResetDefaultOptions1 < YARD::Options
o.reset_defaults
o.foo.should == 'FOO'
end
+
+ it "should use defaults from superclass as well" do
+ class ResetDefaultOptions2 < YARD::Options
+ default_attr :foo, 'FOO'
+ end
+ class ResetDefaultOptions3 < ResetDefaultOptions2
+ end
+ o = ResetDefaultOptions3.new
+ o.reset_defaults
+ o.foo.should == 'FOO'
+ end
end
describe '#delete' do
Please sign in to comment.
Something went wrong with that request. Please try again.