Class: Katalyst::Content::Editor::BaseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
HtmlAttributes
Defined in:
app/components/katalyst/content/editor/base_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container:, item: nil) ⇒ BaseComponent

Returns a new instance of BaseComponent.



13
14
15
16
17
18
# File 'app/components/katalyst/content/editor/base_component.rb', line 13

def initialize(container:, item: nil, **)
  super(**)

  @container = container
  @item = item
end

Instance Attribute Details

#containerObject

Returns the value of attribute container.



9
10
11
# File 'app/components/katalyst/content/editor/base_component.rb', line 9

def container
  @container
end

#itemObject

Returns the value of attribute item.



9
10
11
# File 'app/components/katalyst/content/editor/base_component.rb', line 9

def item
  @item
end

Instance Method Details

#attributes_scopeObject



26
27
28
# File 'app/components/katalyst/content/editor/base_component.rb', line 26

def attributes_scope
  "#{container.model_name.param_key}[items_attributes][]"
end

#callObject



20
# File 'app/components/katalyst/content/editor/base_component.rb', line 20

def call; end

#container_form_idObject



22
23
24
# File 'app/components/katalyst/content/editor/base_component.rb', line 22

def container_form_id
  dom_id(container, :items)
end

#inspectObject



30
31
32
33
34
35
36
# File 'app/components/katalyst/content/editor/base_component.rb', line 30

def inspect
  if item.present?
    "<#{self.class.name} container: #{container.inspect}, item: #{item.inspect}>"
  else
    "<#{self.class.name} container: #{container.inspect}>"
  end
end