When using CacheCrispies inside a Rails application that is split up in Rails Engines, the file path resolved is not correct: the assumption is made that serializers always reside under the Rails application root (Rails.root.join("app/serializers")), while they could actually reside under the engine root.
This PR introduces a method on serializer classes that allow to set the Engine class in order to resolve the file path correctly. This value is inherited when subclassing serializers.
class RailsSerializer
end
# Assuming MyApp::Engine resides under `components` directory in Rails root
class EngineSerializer
engine MyApp::Engine
end
RailsSerializer.send(:path)
# => #<Pathname:/app/serializers/rails_serializer.rb>
EngineSerializer.send(:path)
# => #<Pathname:/components/app/serializers/engine_serializer.rb>
When using CacheCrispies inside a Rails application that is split up in Rails Engines, the file path resolved is not correct: the assumption is made that serializers always reside under the Rails application root (
Rails.root.join("app/serializers")
), while they could actually reside under the engine root. This PR introduces a method on serializer classes that allow to set the Engine class in order to resolve the file path correctly. This value is inherited when subclassing serializers.