module Sequel::Plugins::StringStripper

  1. lib/sequel/plugins/string_stripper.rb

StringStripper is a plugin that strips all input strings when assigning to the model’s values. Example:

album = ' A ') # => 'A'

SQL::Blob instances and all non-strings are not modified by this plugin. Additionally, strings passed to a blob column setter are also not modified. You can explicitly set other columns to skip the stripping:

Album.skip_string_stripping :foo ' A ').foo # => ' A '


# Make all model subclass instances strip strings (called before loading subclasses)
Sequel::Model.plugin :string_stripper

# Make the Album class strip strings
Album.plugin :string_stripper


Public Class

  1. apply
  2. configure

Public Class methods

[show source]
   # File lib/sequel/plugins/string_stripper.rb
27 def self.apply(model)
28   model.plugin(:input_transformer, :string_stripper){|v| (v.is_a?(String) && !v.is_a?(SQL::Blob)) ? v.strip : v}
29 end
[show source]
   # File lib/sequel/plugins/string_stripper.rb
30 def self.configure(model)
31   model.send(:set_skipped_string_stripping_columns)
32 end