alphagov/maslow — pull request #49 by JordanHatch (2013-12-09 13:48:09+00:00)
Title: Refactor handling read-only fields in Need model

Currently, read-only fields have to be defined in three places and it's cumbersome when we need to add more.

This commit refactors the Need model so that it now stores a list of read-only fields as an array. On initialize, we can iterate over this to assign the values to instance variables of the same name.

To do this, the names of the attributes need to be consistent in both the API response and the instance variables, so I've renamed the `@need_id` instance variable to `@id`, and added an alias so that both reader methods continue to work.

I've also added the new `applies_to_all_organisations` field to the list of read-only fields.