Class: ERBLint::Linters::ArgumentMappers::CloseButton
- Defined in:
- lib/primer/view_components/linters/argument_mappers/close_button.rb
Overview
Maps classes in a close-button element to arguments for the CloseButton component.
Constant Summary collapse
- ATTRIBUTES =
%w[type].freeze
- TYPE_OPTIONS =
Primer::ViewComponents::Constants.get( component: "Primer::Beta::CloseButton", constant: "TYPE_OPTIONS" ).freeze
- DEFAULT_TYPE =
Primer::ViewComponents::Constants.get( component: "Primer::Beta::CloseButton", constant: "DEFAULT_TYPE" ).freeze
- DEFAULT_CLASS =
"close-button"
Constants inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#initialize, #map_classes, #system_arguments_to_args, #to_args, #to_s
Constructor Details
This class inherits a constructor from ERBLint::Linters::ArgumentMappers::Base
Instance Method Details
#attribute_to_args(attribute) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/primer/view_components/linters/argument_mappers/close_button.rb', line 24 def attribute_to_args(attribute) # button is the default type, so we don't need to do anything. return {} if attribute.value == DEFAULT_TYPE raise ConversionError, "CloseButton component does not support type \"#{attribute.value}\"" unless TYPE_OPTIONS.include?(attribute.value) { type: ":#{attribute.value}" } end |
#classes_to_args(classes) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/primer/view_components/linters/argument_mappers/close_button.rb', line 33 def classes_to_args(classes) classes.each_with_object({ classes: [] }) do |class_name, acc| next if class_name == DEFAULT_CLASS acc[:classes] << class_name end end |