Sha256: 126e6bfb0db602c79fbe6db9657e82eb88ba9e6b145635b3411cf786edc9404c
Contents?: true
Size: 437 Bytes
Versions: 5
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([]) { |r, v|r << yield(v); r } end end
Version data entries
5 entries across 5 versions & 1 rubygems