README.md in data_cleansing-0.5.0 vs README.md in data_cleansing-0.6.0
- old
+ new
@@ -50,11 +50,11 @@
### Ruby Example
```ruby
require 'data_cleansing'
# Define a global cleaner
-DataCleansing.register_cleaner(:strip) {|string| string.strip!}
+DataCleansing.register_cleaner(:strip) {|string| string.strip}
class User
include DataCleansing::Cleanse
attr_accessor :first_name, :last_name
@@ -76,21 +76,21 @@
### Rails Example
```ruby
# Define a global cleanser
-DataCleansing.register_cleaner(:strip) {|string| string.strip!}
+DataCleansing.register_cleaner(:strip) {|string| string.strip}
# 'users' table has the following columns :first_name, :last_name, :address1, :address2
class User < ActiveRecord::Base
include DataCleansing::Cleanse
# Use a global cleaner
cleanse :first_name, :last_name, :cleaner => :strip
# Define a once off cleaner
- cleanse :address1, :address2, :cleaner => Proc.new {|string| string.strip!}
+ cleanse :address1, :address2, :cleaner => Proc.new {|string| string.strip}
# Automatically cleanse data before validation
before_validation :cleanse_attributes!
end
@@ -106,23 +106,23 @@
```ruby
require 'data_cleansing'
# Define a global cleaners
-DataCleansing.register_cleaner(:strip) {|string| string.strip!}
-DataCleansing.register_cleaner(:upcase) {|string| string.upcase!}
+DataCleansing.register_cleaner(:strip) {|string| string.strip}
+DataCleansing.register_cleaner(:upcase) {|string| string.upcase}
class User
include DataCleansing::Cleanse
attr_accessor :first_name, :last_name, :title, :address1, :address2, :gender
# Use a global cleaner
cleanse :first_name, :last_name, :cleaner => :strip
# Define a once off cleaner
- cleanse :address1, :address2, :cleaner => Proc.new {|string| string.strip!}
+ cleanse :address1, :address2, :cleaner => Proc.new {|string| string.strip}
# Use multiple cleaners, and a custom block
cleanse :title, :cleaner => [:strip, :upcase, Proc.new {|string| "#{string}." unless string.end_with?('.')}]
# Change the cleansing rule based on the value of other attributes in that instance of user
@@ -173,10 +173,10 @@
# Set to :info to log only those fields which were nilled out
# Set to :warn or higher to disable logging of cleansing actions
config.data_cleansing.logger.level = :info
# Register any global cleaners
- config.data_cleansing.register_cleaner(:strip) {|string| string.strip!}
+ config.data_cleansing.register_cleaner(:strip) {|string| string.strip}
end
end
```