jasmine-headless-webkit/lib/jasmine/headless/unique_asset_list.rb

17 lines
392 B
Ruby
Raw Normal View History

2011-11-25 21:18:06 +00:00
module Jasmine::Headless
class UniqueAssetList < ::Array
def <<(asset)
raise InvalidUniqueAsset.new("Not an asset: #{asset.inspect}") if !asset.respond_to?(:logical_path)
2011-11-25 21:18:06 +00:00
super if !self.any? { |other| asset.logical_path == other.logical_path }
end
def flatten
self.collect(&:to_a).flatten
end
end
class InvalidUniqueAsset < StandardError ; end
2011-11-25 21:18:06 +00:00
end