# CREDIT George Moschovitis

require 'facets/more/functor'

module Enumerable

  # Project has_many Group
  # Group has_many User
  # projects.groups.accumulate.users
  #--
  # gmosx: any idea for a better name?
  #++

  def accumulate
    Functor.new do |op, *args|
      self.inject([]) { |a, x| a << x.send(op, *args) }.flatten
    end  
  end
  #alias_method :acc, :accumulate

end


