Class: Neo4j::AsciidoctorExtensions::StageSlugTreeProcessor

Inherits:
AttributeUpdateTreeProcessor show all
Defined in:
lib/neo4j/asciidoctor/extensions/attribute_update/extension.rb

Overview

A tree processor that update the “slug” attribute depending on the “stage” attribute.

Constant Summary collapse

TESTING_SLUG_PREFIX =
'_testing_'

Instance Method Summary collapse

Methods inherited from AttributeUpdateTreeProcessor

#process

Constructor Details

#initialize(config = nil) ⇒ StageSlugTreeProcessor

Returns a new instance of StageSlugTreeProcessor.



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/neo4j/asciidoctor/extensions/attribute_update/extension.rb', line 31

def initialize(config = nil)
  super
  @config[:attr_name] = 'slug'
  @config[:update_rule] = lambda { |document, value|
    case document.attr('stage')
    when 'production'
      value
    else
      "#{TESTING_SLUG_PREFIX}#{value}"
    end
  }
end