Skip to content

Creates an easy way to map column names from what you want to what your (legacy) database define.

License

Notifications You must be signed in to change notification settings

reidmix/legacy_mappings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LegacyMappings

Creates an easy way to map column names from what you want to what your (legacy) database define.

Installation

Put legacy_mappings into your vendor/plugins directory

Example

Define your mappings from your legacy column names to your preferred ones:

class LegacyTable < ActiveRecord::Table
  uses_legacy_mappings :ContantizedColumnName => :name, :annoyingCamelCasedFlag => :flag
end

You should then be able to set, access, and find by your new names:

l = LegacyTable.create!(:name => 'foo', :flag => true)
l.flag = false
l.name?                                                   #=> true
LegacyTable.find(:all, {:name => 'foo'})                  #=> l
LegacyTable.find_by_name('foo')                           #=> l

Currently find only works with the hash version. String, conditions array, and name bind conditions do not work (unless you want to contribute and add them, would be very cool to have.)

Copyright © 2009 Reid MacDonald <reid@laruby.com>, released under the MIT license

About

Creates an easy way to map column names from what you want to what your (legacy) database define.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages