Class: Alchemy::Ingredients::BaseView

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/alchemy/ingredients/base_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ingredient, html_options: {}) ⇒ BaseView

Returns a new instance of BaseView.

Parameters:

  • ingredient (Alchemy::Ingredient)
  • html_options (Hash) (defaults to: {})

    Options that will be passed to the wrapper tag.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
# File 'app/components/alchemy/ingredients/base_view.rb', line 11

def initialize(ingredient, html_options: {})
  raise ArgumentError, "Ingredient missing!" if ingredient.nil?

  @ingredient = ingredient
  @html_options = html_options
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



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

def html_options
  @html_options
end

#ingredientObject (readonly)

Returns the value of attribute ingredient.



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

def ingredient
  @ingredient
end

Instance Method Details

#callObject



18
19
20
# File 'app/components/alchemy/ingredients/base_view.rb', line 18

def call
  value
end

#render?Boolean

Returns:



22
23
24
# File 'app/components/alchemy/ingredients/base_view.rb', line 22

def render?
  value.present?
end