Module: StimulusAttrs::DefaultIdentifier::ClassMethods

Defined in:
lib/stimulus_attrs/default_identifier.rb

Instance Method Summary collapse

Instance Method Details

#identifier_for_stimulus_attrsObject



5
6
7
8
9
# File 'lib/stimulus_attrs/default_identifier.rb', line 5

def identifier_for_stimulus_attrs
  # Convert things like 'Admin::UserAvatarComponent' to 'admin--user-avatar'
  @identifier_for_stimulus_attrs ||= name.gsub('::Component', '').gsub(/Component$/, '')
                                         .underscore.gsub('/', '--').gsub('_', '-')
end