Add configuration option to disallow missing attributes #389

Merged
merged 2 commits into from Jan 23, 2013

Projects

None yet

3 participants

@ReneB

When the configuration option is set to true, a RuntimeError is raised whenever the object being rendered does not have the attribute that is to be rendered.

This allows easier API-compliance testing at development time. One could specify that it is an error to render objects with missing attributes and easily see where it went wrong during development, but use the robustness of RABL rendering in other modes.

The alternative is using :if blocks with all your attributes, but this is a lot of yak-shaving for naught.

An example use case is combining RABL rendering with View Models or Presenters. If a developer forgets to decorate a certain object with a certain presenter, the API may break almost invisibly due to the respond_to? check for missing attributes.

Rene van den... added some commits Jan 15, 2013
Rene van den Berg Add a configuration option that specifies if missing attributes are a…
…n error

This allows easier API-compliance testing at development time. One could
specify that it is an error to render objects with missing attributes
and easily see where it went wrong in development mode, but use the
robustness of RABL rendering in other modes.
3840c30
Rene van den Berg Add meaningful message to error raised on missing attribute 1883cf2
@ReneB

I see the Travis build fails, but I'm not sure why - the tests are not, for as far as I can see, requiring extra files or gems. Could you enlighten me?

@databyte
Collaborator

I haven't looked at the PR itself but Travis tests on all major versions of Ruby.

Rubinius seems to be failing from a previous commit in PR #381.

I think you're safe. I need to find time tonight to review and accept these...

@ReneB

Any word on this?

@nesquena nesquena merged commit 1883cf2 into nesquena:master Jan 23, 2013

1 check failed

Details default The Travis build failed
@nesquena
Owner

Yeah this looks good, tests all pass and the PR was great, thanks for updating docs and writing accompanying tests. Will be a part of the next release.

@nesquena
Owner

BTW @databyte the error for rbx on travis is about installing messagepack. May have to remove rubinius for now since I have no idea why msgpack doesn't install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment