{"action":"created","issue":{"url":"https://api.github.com/repos/Erol/ethos/issues/17","labels_url":"https://api.github.com/repos/Erol/ethos/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/Erol/ethos/issues/17/comments","events_url":"https://api.github.com/repos/Erol/ethos/issues/17/events","html_url":"https://github.com/Erol/ethos/issues/17","id":58442178,"number":17,"title":"Collection directive","user":{"login":"cecillem","id":353784,"avatar_url":"https://avatars.githubusercontent.com/u/353784?v=3","gravatar_id":"","url":"https://api.github.com/users/cecillem","html_url":"https://github.com/cecillem","followers_url":"https://api.github.com/users/cecillem/followers","following_url":"https://api.github.com/users/cecillem/following{/other_user}","gists_url":"https://api.github.com/users/cecillem/gists{/gist_id}","starred_url":"https://api.github.com/users/cecillem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cecillem/subscriptions","organizations_url":"https://api.github.com/users/cecillem/orgs","repos_url":"https://api.github.com/users/cecillem/repos","events_url":"https://api.github.com/users/cecillem/events{/privacy}","received_events_url":"https://api.github.com/users/cecillem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-21T04:35:08Z","updated_at":"2015-02-21T06:29:20Z","closed_at":null,"body":"It would be nice to have a directive to define a collection, such as:\r\n```\r\nclass BookShelf\r\n  collection :books, :Book\r\nend\r\n```\r\n\r\nAlso, it would be nice to make the collection classes lazy loadable"},"comment":{"url":"https://api.github.com/repos/Erol/ethos/issues/comments/75358735","html_url":"https://github.com/Erol/ethos/issues/17#issuecomment-75358735","issue_url":"https://api.github.com/repos/Erol/ethos/issues/17","id":75358735,"user":{"login":"Erol","id":20772,"avatar_url":"https://avatars.githubusercontent.com/u/20772?v=3","gravatar_id":"","url":"https://api.github.com/users/Erol","html_url":"https://github.com/Erol","followers_url":"https://api.github.com/users/Erol/followers","following_url":"https://api.github.com/users/Erol/following{/other_user}","gists_url":"https://api.github.com/users/Erol/gists{/gist_id}","starred_url":"https://api.github.com/users/Erol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Erol/subscriptions","organizations_url":"https://api.github.com/users/Erol/orgs","repos_url":"https://api.github.com/users/Erol/repos","events_url":"https://api.github.com/users/Erol/events{/privacy}","received_events_url":"https://api.github.com/users/Erol/received_events","type":"User","site_admin":false},"created_at":"2015-02-21T06:29:20Z","updated_at":"2015-02-21T06:29:20Z","body":"Lazy evaluation of attribute classes would indeed be useful, and I'm more inclined to go with how Ohm does it - your example's approach - compared to AR.\r\n\r\nI'm still not sure if we should do coercions when the collection array is mutated. [Virtus](https://github.com/solnic/virtus) doesn't seem to do it and suggests the introduction of a collection class. Taken from the Virtus README:\r\n\r\n    # This will coerce Hash to a Book instance\r\n    library.books = [ { :title => 'Introduction to Virtus' } ]\r\n\r\n    # This WILL NOT COERCE the value because you mutate the books array with Array#<<\r\n    library.books << { :title => 'Another Introduction to Virtus' }\r\n\r\nBut, I personally find this coercion use case interesting. There might be merit in implementing our own collection class which has built-in support for coercion."}}