Module: StripAttribute

Extended by:
ActiveSupport::Concern
Included in:
Ci::FreezePeriod, Ci::PipelineSchedule, CustomerRelations::Contact, CustomerRelations::Organization, Issuable, TimeTracking::TimelogCategory, Timebox, User
Defined in:
app/models/concerns/strip_attribute.rb

Overview

Strip Attribute module

Contains functionality to remove leading and trailing whitespace from the attribute before validation

Usage:

class Milestone < ApplicationRecord
  strip_attributes! :title
end

Instance Method Summary collapse

Instance Method Details

#strip_attributes!Object


32
33
34
35
36
# File 'app/models/concerns/strip_attribute.rb', line 32

def strip_attributes!
  self.class.strip_attrs.each do |attr|
    self[attr].strip! if self[attr] && self[attr].respond_to?(:strip!)
  end
end