Class: Alchemy::Ingredients::LinkView
- Includes:
- LinkTarget
- Defined in:
- app/components/alchemy/ingredients/link_view.rb
Constant Summary
Constants included from LinkTarget
Alchemy::Ingredients::LinkTarget::BLANK_VALUE, Alchemy::Ingredients::LinkTarget::REL_VALUE
Instance Attribute Summary collapse
-
#link_text ⇒ Object
readonly
Returns the value of attribute link_text.
Attributes inherited from BaseView
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ingredient, text: nil, html_options: {}) ⇒ LinkView
constructor
A new instance of LinkView.
Methods included from LinkTarget
#link_rel_value, #link_target_value
Methods inherited from BaseView
Constructor Details
#initialize(ingredient, text: nil, html_options: {}) ⇒ LinkView
Returns a new instance of LinkView.
11 12 13 14 |
# File 'app/components/alchemy/ingredients/link_view.rb', line 11 def initialize(ingredient, text: nil, html_options: {}) super(ingredient, html_options: ) @link_text = settings_value(:text, value: text, default: value) end |
Instance Attribute Details
#link_text ⇒ Object (readonly)
Returns the value of attribute link_text.
6 7 8 |
# File 'app/components/alchemy/ingredients/link_view.rb', line 6 def link_text @link_text end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/components/alchemy/ingredients/link_view.rb', line 16 def call target = ingredient.link_target.presence link_to(link_text, value, { target: link_target_value(target), rel: link_rel_value(target) }.merge()).html_safe end |