Class: Middleman::ProcFilter

Inherits:
Filter
  • Object
show all
Defined in:
middleman-core/lib/middleman-core/filter.rb

Constant Summary

Constants included from Contracts

Contracts::ImmutableSortedSetOf, Contracts::PATH_MATCHER

Instance Attribute Summary

Attributes inherited from Filter

#after_filter, #filter_name

Instance Method Summary collapse

Methods inherited from Filter

#<=>

Methods included from Contracts

#Contract

Constructor Details

#initialize(filter_name, callable, options_hash = ::Middleman::EMPTY_HASH) ⇒ ProcFilter

Returns a new instance of ProcFilter.


46
47
48
49
50
# File 'middleman-core/lib/middleman-core/filter.rb', line 46

def initialize(filter_name, callable, options_hash = ::Middleman::EMPTY_HASH)
  super(filter_name, options_hash)

  @callable = callable
end

Instance Method Details

#execute_filter(body) ⇒ Object


53
54
55
56
# File 'middleman-core/lib/middleman-core/filter.rb', line 53

def execute_filter(body)
  result = @callable.call(body)
  result.is_a?(Array) ? result : [result, ::Hamster::Set.empty]
end