lib/eco/language/models/collection.rb in eco-helpers-1.3.1 vs lib/eco/language/models/collection.rb in eco-helpers-1.3.2
- old
+ new
@@ -152,13 +152,12 @@
def contains(attr, value, modifier = Language::MatchModifier.new)
modifier = modifier.new.pattern
self.attr(attr, value, modifier)
end
- def group_by(attr)
- to_h(attr)
- #return {} if !attr
- #self.to_a.group_by { |object| object.method(attr).call }
+ def group_by(attr = nil, &block)
+ return to_h(attr) if attr
+ to_a.group_by(&block) if block
end
def to_h(attr)
return {} if !attr
to_a.group_by { |object| object.method(attr).call }