Class: Vident::ViewComponent::Core

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
lib/vident/view_component/core.rb

Direct Known Subclasses

Base

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.component_pathObject



21
22
23
# File 'lib/vident/view_component/core.rb', line 21

def component_path
  File.join components_base_path, "#{virtual_path}.rb"
end

.components_base_pathObject



25
26
27
# File 'lib/vident/view_component/core.rb', line 25

def components_base_path
  ::Rails.configuration.view_component.view_component_path || "app/components"
end

.current_component_modified_timeObject



5
6
7
# File 'lib/vident/view_component/core.rb', line 5

def current_component_modified_time
  sidecar_view_modified_time + rb_component_modified_time
end

.rb_component_modified_timeObject



13
14
15
# File 'lib/vident/view_component/core.rb', line 13

def rb_component_modified_time
  ::File.exist?(component_path) ? ::File.mtime(component_path).to_i.to_s : ""
end

.sidecar_view_modified_timeObject



9
10
11
# File 'lib/vident/view_component/core.rb', line 9

def sidecar_view_modified_time
  ::File.exist?(template_path) ? ::File.mtime(template_path).to_i.to_s : ""
end

.template_pathObject



17
18
19
# File 'lib/vident/view_component/core.rb', line 17

def template_path
  File.join components_base_path, "#{virtual_path}.html.erb"
end

Instance Method Details

#parent_elementObject Also known as: root

Helper to create the main element



31
32
33
# File 'lib/vident/view_component/core.rb', line 31

def parent_element
  @parent_element ||= ::Vident::ViewComponent::RootComponent.new(**stimulus_options_for_root_component)
end