Class: Stove::Filter

Inherits:
Object
  • Object
show all
Includes:
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



36
37
38
39
40
# File 'lib/stove/filter.rb', line 36

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)


24
25
26
# File 'lib/stove/filter.rb', line 24

def block
  @block
end

#klass~Plugin::Base (readonly)

The class that created this filter.

Returns:



10
11
12
# File 'lib/stove/filter.rb', line 10

def klass
  @klass
end

#messageString (readonly)

The message given by the filter.

Returns:

  • (String)


17
18
19
# File 'lib/stove/filter.rb', line 17

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



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

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

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