Class: Middleman::ProcFilter

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

Constant Summary

Constants included from Contracts

Contracts::ImmutableSetOf, Contracts::ImmutableSortedSetOf, Contracts::OldResourceList, Contracts::PATH_MATCHER, Contracts::ResourceList, Contracts::VectorOf

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


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

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


51
52
53
54
# File 'middleman-core/lib/middleman-core/filter.rb', line 51

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