Created
August 30, 2012 00:19
-
-
Save jisraelsen/3520879 to your computer and use it in GitHub Desktop.
Implicit record filtering in Drudgery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = Drudgery::Manager.new | |
m.prepare do |job| | |
job.extract :csv, 'src/addresses.csv' | |
job.transform do |data, cache| | |
if data[:active] | |
first_name, last_name = data.delete(:name).split(' ') | |
data[:first_name] = first_name | |
data[:last_name] = last_name | |
data[:state] = data.delete(:state_abbr) | |
data | |
else | |
# if nil is returned... this record will be filtered | |
end | |
end | |
job.load :active_record, Address | |
end | |
m.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment