Module: ActiveModel::AttributeFilters::Common::Strip

Included in:
ActiveModel::AttributeFilters::Common
Defined in:
lib/attribute-filters/common_filters/strip.rb

Overview

Strips attributes from leading and trailing spaces.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from FilteringRegistration

#filtering_method

Instance Method Details

#strip_attributes

Note:

If a value of currently processed attribute is an array then any element of the array is changed. The same with hash (its values are changed).

This method returns an undefined value.

Strips attributes from leading and trailing spaces.

The attrubutes to be stripped are taken from the attribute set called should_be_stripped. It operates directly on attribute’s contents.



27
28
29
30
31
# File 'lib/attribute-filters/common_filters/strip.rb', line 27

def strip_attributes
  filter_attrs_from_set(:should_be_stripped) do |atr|
    AFHelpers.each_element(atr, String) { |v| v.strip }
  end
end