Sha256: f3b344c892b645f13ec42701d6e0c23ebfb27687796cc506ec1fe7d11214eb03

Contents?: true

Size: 381 Bytes

Versions: 49

Compression:

Stored size: 381 Bytes

Contents

# encoding: UTF-8

module GovspeakSmartQuotesFixer
  def self.included(model)
    model.class_eval do
      before_validation :fix_smart_quotes_in_govspeak
    end
  end

  private

  def fix_smart_quotes_in_govspeak
    self.class::GOVSPEAK_FIELDS.each do |field|
      if self.send(field) =~ /[“”]/
        self.send(field).gsub!(/[“”]/, '"')
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
govuk_content_models-12.0.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-11.4.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-11.3.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-11.2.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-11.1.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-11.0.1 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-11.0.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.5.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.4.2 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.4.1 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.4.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.3.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.2.2 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.2.1 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.2.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.1.2 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.1.1 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.1.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-10.0.0 app/traits/govspeak_smart_quotes_fixer.rb
govuk_content_models-9.0.1 app/traits/govspeak_smart_quotes_fixer.rb