Class: Primer::BaseComponent
- Defined in:
- app/components/primer/base_component.rb
Overview
Base component used by other Primer components.
Constant Summary collapse
- TEST_SELECTOR_TAG =
:test_selector
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag:, classes: nil, **args) ⇒ BaseComponent
constructor
A new instance of BaseComponent.
Methods included from FetchOrFallbackHelper
Methods included from ClassNameHelper
Constructor Details
#initialize(tag:, classes: nil, **args) ⇒ BaseComponent
Returns a new instance of BaseComponent.
14 15 16 17 18 19 20 |
# File 'app/components/primer/base_component.rb', line 14 def initialize(tag:, classes: nil, **args) @tag = tag @result = Primer::Classify.call(**args.merge(classes: classes)) # Filter out Primer keys so they don't get assigned as HTML attributes @content_tag_args = add_test_selector(args).except(*Primer::Classify::VALID_KEYS) end |
Instance Method Details
#call ⇒ Object
22 23 24 |
# File 'app/components/primer/base_component.rb', line 22 def call content_tag(@tag, content, **@content_tag_args.merge(@result)) end |