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::ImmutableSetOf, Contracts::ImmutableSortedSetOf, Contracts::OldResourceList, Contracts::PATH_MATCHER, Contracts::ResourceList, Contracts::VectorOf

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



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

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



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

def after_filter
  @after_filter
end

#filter_nameObject (readonly)

Returns the value of attribute filter_name



11
12
13
# File 'middleman-core/lib/middleman-core/filter.rb', line 11

def filter_name
  @filter_name
end

Instance Method Details

#<=>(other) ⇒ Object



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

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)


37
38
39
# File 'middleman-core/lib/middleman-core/filter.rb', line 37

def execute_filter(_body)
  raise NotImplementedError
end