Skip to content

Commit

Permalink
Change @disabled to @enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed May 13, 2024
1 parent 4b47e13 commit 0e428d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
18 changes: 11 additions & 7 deletions lib/graft/callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,37 @@ def initialize(name = nil, opts = {}, &block)
@name = name
@opts = opts
@block = block
@disabled = false
@enabled = true
end

if RUBY_VERSION < "3.0"
def call(*args, &block)
return if @disabled
return unless enabled?

@block.call(*args, &block)
end
else
def call(*args, **kwargs, &block)
return if @disabled
return unless enabled?

@block.call(*args, **kwargs, &block)
end
end

def enable
@enabled = true
end

def disable
@disabled = true
@enabled = false
end

def enable
@disabled = false
def enabled?
@enabled
end

def disabled?
@disabled
!enabled?
end
end
end
12 changes: 8 additions & 4 deletions lib/graft/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.ignore
attr_reader :point, :stack

def initialize(hook_point, dependency_test = nil, strategy = DEFAULT_STRATEGY)
@disabled = false
@enabled = true
@point = hook_point.is_a?(HookPoint) ? hook_point : HookPoint.new(hook_point, strategy)
@dependency_test = dependency_test || proc { point.exist? }
@stack = Stack.new
Expand Down Expand Up @@ -69,15 +69,19 @@ def depends_on(&block)
end

def enable
@disabled = false
@enabled = true
end

def disable
@disabled = true
@enabled = false
end

def enabled?
@enabled
end

def disabled?
@disabled
!enabled?
end

def install
Expand Down

0 comments on commit 0e428d4

Please sign in to comment.