class RSpec::Raml::ExclusionFilter
Constants
- ANYTHING
Public Class Methods
new(excludes)
click to toggle source
# File lib/rspec/raml/exclusion_filter.rb, line 6 def initialize(excludes) @excludes = excludes end
Public Instance Methods
filter(object)
click to toggle source
# File lib/rspec/raml/exclusion_filter.rb, line 10 def filter(object) @excludes.reduce object do |acc, exclude| replace(acc, exclude) end end
Private Instance Methods
replace(body, exclude)
click to toggle source
# File lib/rspec/raml/exclusion_filter.rb, line 18 def replace(body, exclude) case exclude when Hash replace_hash(body, exclude) when Array replace_array(body, exclude) when Symbol, String body.merge(exclude.to_s => ANYTHING) else body end end
replace_array(body, exclude)
click to toggle source
# File lib/rspec/raml/exclusion_filter.rb, line 37 def replace_array(body, exclude) case body when Array body.map { |item| replace(item, exclude) } when Hash exclude.reduce(body) { |acc, key| replace(acc, key) } else body end end
replace_hash(body, exclude)
click to toggle source
# File lib/rspec/raml/exclusion_filter.rb, line 31 def replace_hash(body, exclude) exclude.reduce(body) do |acc, (k, v)| acc.merge(k.to_s => replace(acc[k.to_s], v)) end end