Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

avoid subclassing Array not to inherit too much methods

  • Loading branch information...
commit 4e16491f068d34bf31dce7b5e7e0730b7b6a6ae0 1 parent c304887
@matz matz authored
Showing with 15 additions and 6 deletions.
  1. +15 −6 tasks/mrbgem_spec.rake
View
21 tasks/mrbgem_spec.rake
@@ -170,19 +170,28 @@ module MRuby
end # Specification
- class List < Array
+ class List
+ include Enumerable
+
+ def initialize
+ @ary = []
+ end
+
+ def each(&b)
+ @ary.each(&b)
+ end
+
def <<(gem)
fail ArgumentError.new("Don't find directory for this GEM") unless gem.respond_to? :dir
- unless include?(gem)
- super(gem)
+ unless @ary.detect {|g| g.dir == gem.dir }
+ @ary << gem
else
# GEM was already added to this list
end
end
- # we assume that a gem with the same directory is equal
- def include?(gem)
- detect {|g| g.dir == gem.dir }
+ def empty?
+ @ary.empty?
end
end # List
end # Gem
Please sign in to comment.
Something went wrong with that request. Please try again.