-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only pass-through kwargs if super class can take them #81
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,6 +557,39 @@ def initialize(other) | |
expect(instance.three).to eq 3 | ||
end | ||
end | ||
|
||
context "autoinject in class and parent with regular argument in super class" do | ||
let(:super_klass) do | ||
Class.new do | ||
attr_reader :other | ||
|
||
def initialize(other) | ||
@other = other | ||
end | ||
end | ||
end | ||
|
||
let(:parent_klass) do | ||
Class.new(super_klass) do | ||
include Test::AutoInject.kwargs[:one, :two] | ||
end | ||
end | ||
|
||
let(:child_class) do | ||
Class.new(parent_klass) do | ||
include Test::AutoInject.kwargs["namespace.three"] | ||
end | ||
end | ||
|
||
it "works" do | ||
instance = child_class.new(:other) | ||
|
||
expect(instance.other).to eq :other | ||
expect(instance.one).to eq 1 | ||
expect(instance.two).to eq 2 | ||
expect(instance.three).to eq 3 | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the expected behavior when you actually pass in kwargs to the constructor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean what is the expected behaviour if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should raise an error when you include auto-injector module and the super constructor is not compatible. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Loud and noisy is good. |
||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it allocate a new array every time when asking for
keyword_names
? If yes, then it would be good to memoize itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I read it,
keyword_names
are already memoized.