Sha256: 8160962ddc830301bd70bcca4a60f046f2983be3d353e9e3b4f5b149b22f3ed8

Contents?: true

Size: 437 Bytes

Versions: 1

Compression:

Stored size: 437 Bytes

Contents

# encoding: utf-8
require 'attr_enumerable/attr_enumerable_helper'

# AttrEnumerable
module AttrEnumerable
  private
    def map_attr(attribute, method_name, *args, &block)
      col = collection
      return [] if col.empty?
      fail ArgumentError, "invalid attribute #{attribute}" unless include_attr?(col.first, attribute)
      attrs = col.map { |v|v.send(attribute) }
      attrs.reduce([]) { |a, e|a << yield(e); a }
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/attr_enumerable/map_attr.rb