Class: Alchemy::ElementsBlockHelper::ElementViewHelper
- Inherits:
-
BlockHelper
- Object
- BlockHelper
- Alchemy::ElementsBlockHelper::ElementViewHelper
- Defined in:
- app/helpers/alchemy/elements_block_helper.rb
Overview
Block-level helper class for element views.
Instance Attribute Summary
Attributes inherited from BlockHelper
Instance Method Summary collapse
-
#has?(name) ⇒ Boolean
Returns true if the given ingredient has a value.
-
#ingredient_by_role(role) ⇒ Object
Return’s the ingredient record by given role.
-
#render(name, options = {}, html_options = {}) ⇒ Object
Renders one of the element’s ingredients.
-
#value(name) ⇒ Object
Returns the value of one of the element’s ingredients.
Methods inherited from BlockHelper
Constructor Details
This class inherits a constructor from Alchemy::ElementsBlockHelper::BlockHelper
Instance Method Details
#has?(name) ⇒ Boolean
Returns true if the given ingredient has a value.
51 52 53 |
# File 'app/helpers/alchemy/elements_block_helper.rb', line 51 def has?(name) element.has_value_for?(name) end |
#ingredient_by_role(role) ⇒ Object
Return’s the ingredient record by given role.
57 58 59 |
# File 'app/helpers/alchemy/elements_block_helper.rb', line 57 def ingredient_by_role(role) element.ingredient_by_role(role) end |
#render(name, options = {}, html_options = {}) ⇒ Object
Renders one of the element’s ingredients.
If the element uses ingredients
it renders the ingredient record.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/alchemy/elements_block_helper.rb', line 31 def render(name, = {}, = {}) renderable = element.ingredient_by_role(name) return if renderable.nil? helpers.render( renderable.as_view_component( options: , html_options: ) ) end |
#value(name) ⇒ Object
Returns the value of one of the element’s ingredients.
45 46 47 |
# File 'app/helpers/alchemy/elements_block_helper.rb', line 45 def value(name) element.value_for(name) end |