Commit e8dcecca authored by Matt Todd's avatar Matt Todd

Add default pipeline instrumentation service

parent ba1d74af
......@@ -65,11 +65,17 @@ module HTML
# Set an ActiveSupport::Notifications compatible object to enable.
attr_accessor :instrumentation_service
class << self
# Public: Default instrumentation service for new pipeline objects.
attr_accessor :default_instrumentation_service
end
def initialize(filters, default_context = {}, result_class = nil)
raise ArgumentError, "default_context cannot be nil" if default_context.nil?
@filters = filters.flatten.freeze
@default_context = default_context.freeze
@result_class = result_class || Hash
@instrumentation_service = self.class.default_instrumentation_service
end
# Apply all filters in the pipeline to the given HTML.
......
......@@ -25,6 +25,15 @@ class HTML::PipelineTest < Test::Unit::TestCase
assert_equal TestFilter.name, payload[:filter]
end
def test_default_instrumentation_service
service = 'default'
Pipeline.default_instrumentation_service = service
pipeline = Pipeline.new [], @context, @result_class
assert_equal service, pipeline.instrumentation_service
ensure
Pipeline.default_instrumentation_service = nil
end
def filter(input)
@pipeline.call(input)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment