lib/alba.rb in alba-2.4.0 vs lib/alba.rb in alba-2.4.1
- old
+ new
@@ -112,10 +112,14 @@
# @return [Class<Alba::Resource>] resource class
def infer_resource_class(name, nesting: nil)
raise Alba::Error, 'Inference is disabled so Alba cannot infer resource name. Set inflector before use.' unless Alba.inflector
const_parent = nesting.nil? ? Object : Object.const_get(nesting)
- const_parent.const_get("#{inflector.classify(name)}Resource")
+ begin
+ const_parent.const_get("#{inflector.classify(name)}Resource")
+ rescue # Retry for serializer
+ const_parent.const_get("#{inflector.classify(name)}Serializer")
+ end
end
# Configure Alba to symbolize keys
def symbolize_keys!
@symbolize_keys = true