Class: Banzai::Filter::ReferenceGathererFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/banzai/filter/reference_gatherer_filter.rb

Overview

HTML filter that gathers all referenced records that the current user has permission to view.

Expected to be run in its own post-processing pipeline.

Instance Method Summary collapse

Constructor Details

#initializeReferenceGathererFilter

Returns a new instance of ReferenceGathererFilter


9
10
11
12
13
# File 'lib/banzai/filter/reference_gatherer_filter.rb', line 9

def initialize(*)
  super

  result[:references] ||= Hash.new { |hash, type| hash[type] = [] }
end

Instance Method Details

#callObject


15
16
17
18
19
20
21
22
23
# File 'lib/banzai/filter/reference_gatherer_filter.rb', line 15

def call
  Querying.css(doc, 'a.gfm').each do |node|
    gather_references(node)
  end

  load_lazy_references unless ReferenceExtractor.lazy?

  doc
end