module RDF::Serializers::LookupChain
Extracted from active_model_serializers
Constants
- BY_NAMESPACE
Uses the controller namespace of the resource to find the serializer
Example:
Api::V3::AuthorsController => Api::V3::AuthorSerializer
- BY_RESOURCE
Standard appending of Serializer to the resource name.
Example:
Author => AuthorSerializer
- BY_RESOURCE_NAMESPACE
Uses the namespace of the resource to find the serializer
Example:
British::Author => British::AuthorSerializer
- DEFAULT
Public Instance Methods
namespace_for(klass)
click to toggle source
# File lib/rdf/serializers/lookup_chain.rb, line 43 def namespace_for(klass) klass.name.deconstantize end
resource_class_name(klass)
click to toggle source
# File lib/rdf/serializers/lookup_chain.rb, line 47 def resource_class_name(klass) klass.name.demodulize end
serializer_from(klass)
click to toggle source
# File lib/rdf/serializers/lookup_chain.rb, line 55 def serializer_from(klass) name = resource_class_name(klass) serializer_from_resource_name(name) end
serializer_from_resource_name(name)
click to toggle source
# File lib/rdf/serializers/lookup_chain.rb, line 51 def serializer_from_resource_name(name) "#{name}Serializer" end