Class: Alchemy::Admin::IngredientEditor
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Alchemy::Admin::IngredientEditor
- Defined in:
- app/components/alchemy/admin/ingredient_editor.rb
Overview
Adapter component for rendering ingredient editors.
Handles both deprecated partial-based editors and component based editors. Use with_collection for efficient batch rendering of ingredients.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ingredient:, element_form: nil) ⇒ IngredientEditor
constructor
A new instance of IngredientEditor.
Constructor Details
#initialize(ingredient:, element_form: nil) ⇒ IngredientEditor
Returns a new instance of IngredientEditor.
26 27 28 29 |
# File 'app/components/alchemy/admin/ingredient_editor.rb', line 26 def initialize(ingredient:, element_form: nil) @ingredient = ingredient @element_form = element_form end |
Instance Method Details
#call ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/alchemy/admin/ingredient_editor.rb', line 31 def call if has_editor_partial? Alchemy::Deprecation.warn <<~WARN Ingredient editor partials are deprecated! Please create a `#{@ingredient.class.name}Editor` class inheriting from `Alchemy::Ingredients::BaseEditor`. WARN Alchemy::Deprecation.silence do render partial: "alchemy/ingredients/#{@ingredient.partial_name}_editor", locals: {element_form: @element_form}, object: Alchemy::IngredientEditor.new(@ingredient) end else render @ingredient.as_editor_component end end |