Class: Stove::Filter

Inherits:
Object
  • Object
show all
Includes:
Logify, Mixin::Insideable
Defined in:
lib/stove/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin::Insideable

#inside

Constructor Details

#initialize(klass, message, &block) ⇒ Filter

Create a new filter object.

Parameters:

  • klass (~Plugin::Base)

    the class that created this filter

  • message (String)

    the message given by the filter

  • block (Proc)

    the block captured by this filter



38
39
40
41
42
# File 'lib/stove/filter.rb', line 38

def initialize(klass, message, &block)
  @klass   = klass
  @message = message
  @block   = block
end

Instance Attribute Details

#blockProc (readonly)

The block captured by the filter.

Returns:

  • (Proc)


26
27
28
# File 'lib/stove/filter.rb', line 26

def block
  @block
end

#klass~Plugin::Base (readonly)

The class that created this filter.

Returns:



12
13
14
# File 'lib/stove/filter.rb', line 12

def klass
  @klass
end

#messageString (readonly)

The message given by the filter.

Returns:

  • (String)


19
20
21
# File 'lib/stove/filter.rb', line 19

def message
  @message
end

Instance Method Details

#run(cookbook, options = {}) ⇒ Object

Execute this filter in the context of the creating class, inside the given cookbook’s path.

Parameters:

  • the (Cookbook)

    cookbook to run this filter against



51
52
53
54
55
56
57
58
# File 'lib/stove/filter.rb', line 51

def run(cookbook, options = {})
  log.info(message)
  instance = klass.new(cookbook, options)

  inside(cookbook) do
    instance.instance_eval(&block)
  end
end