lib/wcc/contentful/services.rb in wcc-contentful-1.5.0.rc1 vs lib/wcc/contentful/services.rb in wcc-contentful-1.5.0
- old
+ new
@@ -9,10 +9,14 @@
end
end
attr_reader :configuration
+ def model_namespace
+ @model_namespace || WCC::Contentful::Model
+ end
+
def initialize(configuration, model_namespace: nil)
raise ArgumentError, 'Not yet configured!' unless configuration
@configuration = configuration
@model_namespace = model_namespace
@@ -129,23 +133,10 @@
# The implementation class is configured by {WCC::Contentful::Configuration#rich_text_renderer}.
# In a rails context the default implementation is {WCC::Contentful::ActionViewRichTextRenderer}.
def rich_text_renderer
@rich_text_renderer ||=
if implementation_class = configuration&.rich_text_renderer
- store = self.store
- config = configuration
- model_namespace = @model_namespace || WCC::Contentful::Model
-
- # Wrap the implementation in a subclass that injects the services
- Class.new(implementation_class) do
- define_method :initialize do |document, *args, **kwargs|
- # Implementation might choose to override these, so call super last
- @store = store
- @config = config
- @model_namespace = model_namespace
- super(document, *args, **kwargs)
- end
- end
+ RichTextRendererFactory.new(implementation_class, services: self)
else
# Create a renderer that renders a more helpful error message, but delay the error message until #to_html
# is actually invoked in case the user never actually uses the renderer.
Class.new(WCC::Contentful::RichTextRenderer) do
def call