Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Extract BaseHookCollection #1132

Merged
merged 1 commit into from
Nov 1, 2013
Merged

Extract BaseHookCollection #1132

merged 1 commit into from
Nov 1, 2013

Conversation

dchelimsky
Copy link
Contributor

Previously the HookCollection was acting as a base with the subclasses
overriding (some) methods. With this change, each subclass extends the
base class by adding new methods, not overriding existing ones. Makes it
all a bit easier to reason about.

def instance_exec(*args, &block)
@example_group_instance.instance_exec(*args, &block)
def instance_exec(example_or_procsy, &block)
@example_group_instance.instance_exec(example_or_procsy, &block)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that we override instance_exec here. Given that it's a core ruby method available on all objects that is expected to behave in a certain way (i.e. eval the block with the object as self) and this does not behave that way...can we rename this to eval_block_in_group or something like that? I'd prefer not to stomp on ruby's version of this method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why did you change this from a splat? It's unclear to me what the connection of this change is to the PR as a whole.

@myronmarston
Copy link
Member

The changes look fine. My concerns above aren't really affected by this PR (as instance_exec was already being overriden), so we can always address that in a separate PR if we decide it's worth doing.

@dchelimsky
Copy link
Contributor Author

The explicit arg instead of splat was to clarify usage. How 'bout I back that change out of this PR and address that and wrapping instance_exec separately?

@myronmarston
Copy link
Member

The explicit arg instead of splat was to clarify usage. How 'bout I back that change out of this PR and address that and wrapping instance_exec separately?

👍

Previously the HookCollection was acting as a base with the subclasses
overriding (some) methods. With this change, each subclass extends the
base class by adding new methods, not overriding existing ones. Makes it
all a bit easier to reason about.
dchelimsky added a commit that referenced this pull request Nov 1, 2013
@dchelimsky dchelimsky merged commit 16eec46 into master Nov 1, 2013
@dchelimsky dchelimsky deleted the hook-collection-hierarchy branch November 1, 2013 14:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants