ismasan/oat — pull request #31 by shekibobo (2014-04-07 16:11:46+00:00)
Title: Don't block NoMethodErrors from raising

This is bad practice, and I'm not quite sure why we do it.

In one case, it has a particularly annoying side-effect of not
being able to turn off the warnings, despite a NoMethodError being
expected.

```ruby
class AssignmentSerializer < Oat::Serializer
include Rails.application.routes.url_helpers
adapter Oat::Adapters::HAL

schema do
link assignable_path(item.assignable) if assignable_path(item.assignable)
end

def assignable_path(assignable)
routable_klass = item.assignable_type.constantize
# don't throw warnings to serializer if the route doesn't exist
@assignable_path ||= begin
polymorphic_path([:api, assignable.becomes(routable_klass)]) if routable_klass
rescue NoMethodError
nil
end
end
end
```

Normal behavior if the route doesn't exist is to throw a `NoMethodError`, but since `Oat::Serializer` doesn't call `super` in `method_missing`, it never gets thrown. Ideally, the user is in charge of handling `NoMethodError`. The warning might be nice, but it's too dangerous to override `method_missing` without calling `super`.