Module: SolidusAdmin::Preview
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/solidus_admin/preview.rb
Overview
This module will add all the necessary harness to a ViewComponent::Preview to be able to render Solidus components.
Adds a current_component helper method that will return the the component class based on the preview class name. The component class name is inferred by removing the Preview suffix from the preview class name.
Adds a helpers method that will return the helpers module from SolidusAdmin::BaseController making them available to the preview class (which is not a standard controller). All helpers are available to the preview class via method_missing.
Defined Under Namespace
Modules: ControllerHelper
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object (private)
70 71 72 73 74 75 76 |
# File 'lib/solidus_admin/preview.rb', line 70 def method_missing(name, ...) if helpers.respond_to?(name) helpers.send(name, ...) else super end end |
Instance Method Details
#current_component ⇒ Object
64 65 66 |
# File 'lib/solidus_admin/preview.rb', line 64 def current_component @current_component ||= self.class.name.chomp("Preview").constantize end |