class Swarker::PathsMerger
Attributes
original_paths[R]
paths[R]
Public Class Methods
new(original_paths)
click to toggle source
# File lib/swarker/paths_merger.rb, line 5 def initialize(original_paths) @original_paths = original_paths @paths = merge(original_paths) end
Private Instance Methods
merge(original_paths)
click to toggle source
# File lib/swarker/paths_merger.rb, line 12 def merge(original_paths) groups = HashWithIndifferentAccess.new original_paths.each do |path| if groups[path_key(path)].nil? groups[path_key(path)] = path else groups[path_key(path)] = merge_paths(groups[path_key(path)], path) end end groups.values end
merge_paths(first_path, second_path)
click to toggle source
# File lib/swarker/paths_merger.rb, line 30 def merge_paths(first_path, second_path) scheme = first_path.schema.dup scheme.values.first[:responses].merge! second_path.schema.values.first[:responses] Swarker::Path.new(first_path.name, scheme, true) end
path_key(path)
click to toggle source
# File lib/swarker/paths_merger.rb, line 26 def path_key(path) "#{path.verb}_#{path.name}" end