Class: Minfra::Cli::Hook::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/minfra/cli/hook.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, names, block) ⇒ Hook

Returns a new instance of Hook.



45
46
47
48
49
# File 'lib/minfra/cli/hook.rb', line 45

def initialize(type, names, block)
  @type = type
  @names = names
  @block = block
end

Instance Method Details

#exec(obj) ⇒ Object



55
56
57
# File 'lib/minfra/cli/hook.rb', line 55

def exec(obj)
  obj.instance_eval(&@block)
end

#match?(type, names) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/minfra/cli/hook.rb', line 51

def match?(type, names)
  @type == type && @names == names.map(&:to_sym)
end