Class: GovukComponent::Base

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
Traits::CustomClasses, Traits::CustomHtmlAttributes
Defined in:
app/components/govuk_component/base.rb

Instance Attribute Summary

Attributes included from Traits::CustomHtmlAttributes

#html_attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Traits::CustomClasses

#classes, #default_classes

Constructor Details

#initialize(classes: [], html_attributes: {}) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'app/components/govuk_component/base.rb', line 5

def initialize(classes: [], html_attributes: {})
  @classes         = parse_classes(classes)
  @html_attributes = html_attributes
end

Class Method Details

.wrap_slot(name) ⇒ Object

Redirect #add_name to #slot(:name) to make building components with slots feel more DSL-like



12
13
14
15
16
# File 'app/components/govuk_component/base.rb', line 12

def self.wrap_slot(name)
  define_method(%(add_#{name})) do |*args, **kwargs, &block|
    slot(name, *args, **kwargs, &block)
  end
end