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 " Ingredient editor partials are deprecated!\n Please create a `\#{@ingredient.class.name}Editor` class inheriting from `Alchemy::Ingredients::BaseEditor`.\n WARN\n Alchemy::Deprecation.silence do\n render partial: \"alchemy/ingredients/\#{@ingredient.partial_name}_editor\",\n locals: {element_form: @element_form},\n object: Alchemy::IngredientEditor.new(@ingredient)\n end\n else\n render @ingredient.as_editor_component\n end\nend\n" |