Class: Alchemy::Ingredients::LinkView

Inherits:
BaseView
  • Object
show all
Defined in:
app/components/alchemy/ingredients/link_view.rb

Instance Attribute Summary collapse

Attributes inherited from BaseView

#html_options, #ingredient

Instance Method Summary collapse

Methods inherited from BaseView

#render?

Constructor Details

#initialize(ingredient, text: nil, html_options: {}) ⇒ LinkView

Returns a new instance of LinkView.

Parameters:

  • ingredient (Alchemy::Ingredient)
  • text (String) (defaults to: nil)

    The link text. If not given, the ingredient’s text setting or the value will be used.

  • html_options (Hash) (defaults to: {})

    Options that will be passed to the a tag.



9
10
11
12
# File 'app/components/alchemy/ingredients/link_view.rb', line 9

def initialize(ingredient, text: nil, html_options: {})
  super(ingredient, html_options: html_options)
  @link_text = settings_value(:text, value: text, default: value)
end

Instance Attribute Details

Returns the value of attribute link_text.



4
5
6
# File 'app/components/alchemy/ingredients/link_view.rb', line 4

def link_text
  @link_text
end

Instance Method Details

#callObject



14
15
16
# File 'app/components/alchemy/ingredients/link_view.rb', line 14

def call
  link_to(link_text, value, {target: link_target}.merge(html_options))
end