Method: JSONAPI::Resource.resource_for
- Defined in:
- lib/jsonapi/resource.rb
.resource_for(type) ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/jsonapi/resource.rb', line 425 def resource_for(type) type = type.underscore type_with_module = type.include?('/') ? type : module_path + type resource_name = _resource_name_from_type(type_with_module) resource = resource_name.safe_constantize if resource_name if resource.nil? fail NameError, "JSONAPI: Could not find resource '#{type}'. (Class #{resource_name} not found)" end resource end |