Class: Core::Watch::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/core/watch/callback.rb

Overview

public

Callback for a watched system.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Callback

Returns a new instance of Callback.



25
26
27
# File 'lib/core/watch/callback.rb', line 25

def initialize(&block)
  @block = block
end

Class Method Details

.build(value, &block) ⇒ Object

public

Build a callback instance for a given value and block.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/core/watch/callback.rb', line 11

def build(value, &block)
  case value
  when Callback
    value
  when ::NilClass
    Callback.new(&block)
  when ::Regexp
    Callbacks::Regexp.new(value, &block)
  else
    Callbacks::Path.new(value, &block)
  end
end

Instance Method Details

#call(*args, **kwargs) ⇒ Object

public

Invoke the callback.



31
32
33
# File 'lib/core/watch/callback.rb', line 31

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

#match?(_) ⇒ Boolean

public

Returns:

  • (Boolean)


37
38
39
# File 'lib/core/watch/callback.rb', line 37

def match?(_)
  true
end