lib/reach.rb in wwood-reach-0.1 vs lib/reach.rb in wwood-reach-0.1.1

- old
+ new

@@ -1,10 +1,10 @@ # Copyright (c) 2008 Ben Woodcroft <donttrustben somewhere near gmail.com> # # This program is free software. # You can distribute/modify this program under the terms of -# the GNU Lesser General Public License version 3. +# the GNU General Public License version 3. # The point of this is that the # Bookshelf.all.reach.books.each do {|book| puts book.name} # instead of # Bookshelf.all.each do |bookshelf| @@ -28,13 +28,12 @@ def initialize(retract) @retract = retract end - # When a method is called on an array and that method - # isn't defined for an array, then run - # + # The method could be missing from the array, the members, or both. + # Try to pass the method to each, in that order, accepting the first taker def method_missing(method, *args, &block) if @retract.respond_to?(method) # If this is an array method, just use that r = @retract.send(method, *args, &block) return r @@ -48,10 +47,15 @@ end return self end end - # Mainly for testing + # Equality test - equality of the underlying retract + # arrays is all that matter def ==(another) @retract <=> another.retract + end + + def to_s + @retract.to_s end end