Class: Middleman::Filter

Inherits:
Object
  • Object
show all
Includes:
Comparable, Contracts
Defined in:
middleman-core/lib/middleman-core/filter.rb

Direct Known Subclasses

InlineURLRewriter, ProcFilter

Constant Summary

Constants included from Contracts

Contracts::ImmutableSortedSetOf, Contracts::PATH_MATCHER

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Contracts

#Contract

Constructor Details

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

Returns a new instance of Filter.


31
32
33
34
35
36
# File 'middleman-core/lib/middleman-core/filter.rb', line 31

def initialize(filter_name, options_hash = ::Middleman::EMPTY_HASH)
  @filter_name = filter_name

  @options = options_hash
  @after_filter = @options.fetch(:after_filter, nil)
end

Instance Attribute Details

#after_filterObject (readonly)

Returns the value of attribute after_filter


16
17
18
# File 'middleman-core/lib/middleman-core/filter.rb', line 16

def after_filter
  @after_filter
end

#filter_nameObject (readonly)

Returns the value of attribute filter_name


13
14
15
# File 'middleman-core/lib/middleman-core/filter.rb', line 13

def filter_name
  @filter_name
end

Instance Method Details

#<=>(other) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
# File 'middleman-core/lib/middleman-core/filter.rb', line 18

def <=>(other)
  shift = if other.after_filter.nil?
            0
          elsif filter_name == other.after_filter
            1
          else
            -1
          end

  [0, object_id] <=> [shift, other.object_id]
end

#execute_filter(_body) ⇒ Object

Raises:

  • (NotImplementedError)

39
40
41
# File 'middleman-core/lib/middleman-core/filter.rb', line 39

def execute_filter(_body)
  raise NotImplementedError
end