lib/jsonapi/resource_for.rb in jsonapi-resources-0.0.13 vs lib/jsonapi/resource_for.rb in jsonapi-resources-0.0.14

- old
+ new

@@ -9,17 +9,21 @@ if RUBY_VERSION >= '2.0' def resource_for(type) resource_name = JSONAPI::Resource._resource_name_from_type(type) Object.const_get resource_name if resource_name rescue NameError - nil + raise NameError, "JSONAPI: Could not find resource '#{type}'. (Class #{resource_name} not found)" end else def resource_for(type) resource_name = JSONAPI::Resource._resource_name_from_type(type) - resource_name.safe_constantize if resource_name + resource = resource_name.safe_constantize if resource_name + if resource.nil? + raise NameError, "JSONAPI: Could not find resource '#{type}'. (Class #{resource_name} not found)" + end + resource end end # :nocov: end end -end \ No newline at end of file +end