Class: Rustic::Hooks

Inherits:
Object
  • Object
show all
Defined in:
lib/rustic/hooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Hooks

Returns a new instance of Hooks.



4
5
6
7
# File 'lib/rustic/hooks.rb', line 4

def initialize(config)
  @before = config&.before
  @after = config&.after
end

Instance Method Details

#with_hooks(arg = nil) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# File 'lib/rustic/hooks.rb', line 9

def with_hooks(arg = nil)
  raise ArgumentError unless block_given?

  @before&.call(arg)
  yield
  @after&.call(arg)
end