everypolitician / everypolitician-popolo

Ruby gem for interacting with EveryPolitician data for a legislature
MIT License
7 stars 4 forks source link

return collections from of_class #117

Closed struan closed 8 years ago

struan commented 8 years ago

of_class was returning arrays so update it to return collections, at the same time updating new_collection to accept an option collection class to instantiate. This means that if you are fetching a collection of sub-classes then you can instantiate the correct collection.

At the moment this is manual so for of_class you have to specify both the Entity class and the Collection class because it's not clear how to link the two. I'm not sure it's possible to specify a collection_class property for an Entity because of ordering - e.g. the Elections class is defined after Election so can't be used in Election.

Fixes #116

chrismytton commented 8 years ago

At the moment this is manual so for of_class you have to specify both the Entity class and the Collection class because it's not clear how to link the two. I'm not sure it's possible to specify a collection_class property for an Entity because of ordering - e.g. the Elections class is defined after Election so can't be used in Election.

After discussing in Slack this was updated to be of_collection to avoid the need to pass two classes.