Slight refactoring

This commit is contained in:
Douwe Maan 2015-10-22 15:40:36 +02:00
parent 51ed8fd706
commit aa4007a597
1 changed files with 2 additions and 10 deletions

View File

@ -11,6 +11,7 @@ module Gitlab
@load_lazy_references = load_lazy_references @load_lazy_references = load_lazy_references
@texts = [] @texts = []
@references = {}
end end
def analyze(text, options = {}) def analyze(text, options = {})
@ -19,21 +20,12 @@ module Gitlab
%i(user label issue merge_request snippet commit commit_range).each do |type| %i(user label issue merge_request snippet commit commit_range).each do |type|
define_method("#{type}s") do define_method("#{type}s") do
references[type] @references[type] ||= pipeline_result(type)
end end
end end
private private
def references
@references ||= Hash.new do |references, type|
type = type.to_sym
next references[type] if references.has_key?(type)
references[type] = pipeline_result(type)
end
end
# Instantiate and call HTML::Pipeline with a single reference filter type, # Instantiate and call HTML::Pipeline with a single reference filter type,
# returning the result # returning the result
# #