Module: AttributesSanitizer::Predefined
- Included in:
- AttributesSanitizer
- Defined in:
- lib/attributes_sanitizer/predefined.rb
Constant Summary collapse
- EMOJI_REGEX =
/[^\u0000-\u00FF]/
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(_) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/attributes_sanitizer/predefined.rb', line 12 def self.extended(_) AttributesSanitizer.define_sanitizer :stringify do |value| value.to_s end AttributesSanitizer.define_sanitizer :downcase do |value| value.downcase end AttributesSanitizer.define_sanitizer :upcase do |value| value.upcase end AttributesSanitizer.define_sanitizer :strip_tags do |value| ActionController::Base.helpers.sanitize(value, tags: []) end AttributesSanitizer.define_sanitizer :strip_emojis do |value| value.gsub(AttributesSanitizer::Predefined::EMOJI_REGEX, '') end AttributesSanitizer.define_sanitizer :strip_spaces do |value| value.strip end AttributesSanitizer.setup_predefined_bundles end |
Instance Method Details
#setup_predefined_bundles ⇒ Object
6 7 8 9 10 |
# File 'lib/attributes_sanitizer/predefined.rb', line 6 def setup_predefined_bundles define_bundle(:predefined, @sanitizers.keys) define_bundle(:no_tags_emojis_or_extra_spaces, %i(stringify strip_tags strip_emojis strip_spaces)) @predefined_bundles = @bundles.keys end |