solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 228 forks source link

AttributeSet#select should return another AttributeSet #286

Open postmodern opened 9 years ago

postmodern commented 9 years ago

Shouldn't AttributeSet#select return a sub-attribute-set?

solnic commented 9 years ago

It's an enumerable that yields attribute instances so default behavior is that you end up with an array. If there's a simple way of making it return an attribute set instance then I'm all for it.

postmodern commented 9 years ago

You would have to override #select to wrap the result in a new AttributeSet. While it would be nice to retain the methods in AttributeSet, #select traditionally returns an Array (even for Hash and Set).

jgdreyes commented 9 years ago

@postmodern At least as of Ruby 1.9.3, Hash#select returns a Hash. I know that this was not the case in Ruby 1.8.7 where it did return an Array.