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.



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.



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

def block
  @block
end

#klass~Plugin::Base (readonly)

The class that created this filter.



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

def klass
  @klass
end

#messageString (readonly)

The message given by the filter.



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.



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