When I first saw this #asset_allowed?
method, I knew there was a nice collection method I could use to clean this up, but couldn't remember and forgot to check the Enumerable module. Stumbled upon the #any?
method while looking at a nice git pre-commit hook in Ruby and thought, "Bingo!".
def asset_allowed?(asset)
self.logical_asset_filter.reduce(false) do |accum, matcher|
accum || (matcher =~ asset)
end ? true : false
end
def asset_allowed?(asset)
self.logical_asset_filter.any? { |matcher| matcher =~ asset }
end