contentful / contentful_model

A lightweight wrapper around the Contentful api gem, to make it behave more like ActiveRecord
MIT License
44 stars 42 forks source link

Update code to match Ruby styleguide #101

Closed dlitvakb closed 6 years ago

andyhansen commented 6 years ago

Hey there, the removal of AttributeNotFoundError has broken some of our code which relied on it. In this case, should we be using NoMethodError instead?

dlitvakb commented 6 years ago

Hey @andyhansen,

Yes, that would be the best solution. I found that there was no benefit internally for wrapping the error as it should be handled in the same way to avoid strange behaviour and some edge cases (there used to be 2 handlers internally, one for NoMethodError and one for AttributeNotFoundError for every single exception check, which made no sense in many cases.

Otherwise, I'd advise to use return_nil_for_empty in the cases in which this is an issue for you.

Hope this explains the reasoning a bit further,

Cheers