lib/tresse.rb in tresse-1.1.1 vs lib/tresse.rb in tresse-1.1.2

- old
+ new

@@ -2,11 +2,11 @@ require 'thread' module Tresse - VERSION = '1.1.1' + VERSION = '1.1.2' class << self def init @@ -142,16 +142,14 @@ end # # sourcing methods - def source(o=nil, &block) + def source(&block) - batch = Tresse::Batch.new(self, o ? o : block) + @batches << Tresse::Batch.new(self, block) - @batches << batch - self end def source_each(collection, &block) @@ -188,10 +186,17 @@ end alias inject reduce def flatten - do_reduce([], lambda { |a, e| a.concat(e) }) + do_reduce( + [], + lambda { |a, e| + if e.respond_to?(:to_a) && ! e.is_a?(Hash) + a.concat(e.to_a) + else + a.push(e) + end }) end alias values flatten protected