Sha256: d1202215073a68701199bcc5c15025e218b5c9feafd958c4dadf1c9f619e3cd8

Contents?: true

Size: 392 Bytes

Versions: 3

Compression:

Stored size: 392 Bytes

Contents

require 'facet/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

# * George Moschovitis <gm@navel.gr>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glue-0.28.0 lib/glue/accumulate.rb
glue-0.29.0 lib/glue/accumulate.rb
glue-0.30.0 lib/glue/accumulate.rb