<commit_before>module FlashRailsMessages
  class Base
    include ActionView::Helpers::TagHelper
    include ActionView::Context

    attr_accessor :options

    def initialize(options = {})
      @options = options
    end

    def render(flash)
      flash.map { |message| alert_element(*message) }.join.html_safe
    end

    private

    def alert_element(type, message)
      content_tag :div, class: alert_classes(type) do
        close_element + message.html_safe
      end
    end

    def close_element
      content_tag :span, class: 'close', :'data-dismiss' => 'alert' do
        '&times;'.html_safe
      end
    end

    def alert_classes(type)
      "#{default_alert_class} #{alert_type_classes[type]} #{custom_alert_class(type)}"
    end

    def default_alert_class
      'alert'
    end

    def alert_type_classes
      {
        success: 'alert-success',
        notice: 'alert-info',
        alert: 'alert-error',
        error: 'alert-error',
      }
    end

    def custom_alert_class(type)
      "alert-#{type}"
    end
  end
end
<commit_msg>Fixing problem with string hash keys<commit_after>module FlashRailsMessages
  class Base
    include ActionView::Helpers::TagHelper
    include ActionView::Context

    attr_accessor :options

    def initialize(options = {})
      @options = options
    end

    def render(flash)
      flash.symbolize_keys.map { |message| alert_element(*message) }.join.html_safe
    end

    private

    def alert_element(type, message)
      content_tag :div, class: alert_classes(type) do
        close_element + message.html_safe
      end
    end

    def close_element
      content_tag :span, class: 'close', :'data-dismiss' => 'alert' do
        '&times;'.html_safe
      end
    end

    def alert_classes(type)
      "#{default_alert_class} #{alert_type_classes[type]} #{custom_alert_class(type)}"
    end

    def default_alert_class
      'alert'
    end

    def alert_type_classes
      {
        success: 'alert-success',
        notice: 'alert-info',
        alert: 'alert-error',
        error: 'alert-error',
      }
    end

    def custom_alert_class(type)
      "alert-#{type}"
    end
  end
end

{'fraction_non_alphanumeric': 0.09907834101382489, 'fraction_numerical': 0.0, 'mean_word_length': 2.5648604269293926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7566959', 'n_tokens_mistral': 678, 'n_tokens_neox': 665, 'n_words': 153}