solnic/virtus — pull request #139 by aptinio (2012-12-18 05:17:16+00:00)
Title: Unable to use a custom class that include Enumerable as an attribute collection

This fixes the ff. issue:

When the ff. BookCollection is used as an attribute collection, the attribute is still an Array.

```ruby
require 'virtus'
require 'forwardable'

class Book
include Virtus
attribute :title, String
end

class BookCollection
extend Forwardable
include Enumerable

def_delegators :@array, :each, :<<

def initialize(*args)
@array = Array.new(*args)
end

def self.[](*args)
Array(args)
end
end

module Virtus
class Attribute
class BookCollection < Collection
primitive ::BookCollection
coercion_method :to_book_collection
default primitive.new

include Collection::MemberCoercion
end
end

class Coercion
class BookCollection < Object
primitive ::BookCollection

def self.to_set(value)
value.to_set
end

end

class Object
def self.to_book_collection(value)
::BookCollection.new value
end
end
end
end

class Library
include Virtus
attribute :books, BookCollection[Book]
end

library = Library.new
library.books.class #=> Array
library.books = []
puts library.books.class #=> Array
```