-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename HookConfiguration to CaptainHook::Configuration
Follow the starndard ruby gem folder structure with a gem_name.rb and a gem_name folder with the rest of the library This makes it predictable for external developers and it will prevent from polluting the global namespace with classes from the gem
- Loading branch information
Showing
4 changed files
with
39 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module CaptainHook | ||
# Hook configuration parameters these determine how a specific hook will run | ||
class Configuration | ||
def initialize( | ||
hook:, | ||
include: [], | ||
inject: [], | ||
exclude: [], | ||
skip_when: nil, | ||
param_builder: nil | ||
) | ||
@hook = hook | ||
@include = include | ||
@inject = inject | ||
@exclude = exclude | ||
@skip_when = skip_when | ||
@param_builder = param_builder | ||
end | ||
|
||
attr_reader :hook, :include, :inject, :exclude, :skip_when, :param_builder | ||
|
||
# This determines if this specific hook should be skipped | ||
# depending on the method or arguments. | ||
def skip?(method, *args, **kwargs) | ||
return true if skip_when&.call(args, kwargs) | ||
return true if exclude.include?(method) | ||
|
||
return false if include.empty? | ||
|
||
!include.include?(method) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters