Class: Vident::ViewComponent::Base
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Vident::ViewComponent::Base
- Includes:
- Component
- Defined in:
- lib/vident/view_component/base.rb
Class Method Summary collapse
- .component_path ⇒ Object
- .components_base_path ⇒ Object
- .current_component_modified_time ⇒ Object
- .rb_component_modified_time ⇒ Object
- .sidecar_view_modified_time ⇒ Object
- .template_path ⇒ Object
Instance Method Summary collapse
-
#parent_element(**options) ⇒ Object
(also: #root)
Helper to create the main element.
Class Method Details
.component_path ⇒ Object
23 24 25 |
# File 'lib/vident/view_component/base.rb', line 23 def component_path File.join components_base_path, "#{virtual_path}.rb" end |
.components_base_path ⇒ Object
27 28 29 |
# File 'lib/vident/view_component/base.rb', line 27 def components_base_path ::Rails.configuration.view_component.view_component_path || "app/components" end |
.current_component_modified_time ⇒ Object
7 8 9 |
# File 'lib/vident/view_component/base.rb', line 7 def current_component_modified_time sidecar_view_modified_time + rb_component_modified_time end |
.rb_component_modified_time ⇒ Object
15 16 17 |
# File 'lib/vident/view_component/base.rb', line 15 def rb_component_modified_time ::File.exist?(component_path) ? ::File.mtime(component_path).to_i.to_s : "" end |
.sidecar_view_modified_time ⇒ Object
11 12 13 |
# File 'lib/vident/view_component/base.rb', line 11 def sidecar_view_modified_time ::File.exist?(template_path) ? ::File.mtime(template_path).to_i.to_s : "" end |
.template_path ⇒ Object
19 20 21 |
# File 'lib/vident/view_component/base.rb', line 19 def template_path File.join components_base_path, "#{virtual_path}.html.erb" end |
Instance Method Details
#parent_element(**options) ⇒ Object Also known as: root
Helper to create the main element
33 34 35 |
# File 'lib/vident/view_component/base.rb', line 33 def parent_element(**) @parent_element ||= RootComponent.new(**parent_element_attributes()) end |