Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save knowtheory/833231 to your computer and use it in GitHub Desktop.

Select an option

Save knowtheory/833231 to your computer and use it in GitHub Desktop.
See how DataMapper is perfect for extracting data from legacy stores without backflips, kungfu, or dangerous acrobatics. You can even use your data extraction models directly in web apps without any fuss.

Abstract

Ruby and Rails are well known for greenfield development, and sits amongst the top choices for startups. However, the expanded world of open data sources, and enterprise Ruby, there's a lot more to life than dreaming up new web apps. But when (not if) you deal with pre-existing data, why spend all your time writing brittle one off shims to translate your data from your legacy store? Why not rely on a robust and well designed Ruby library like DataMapper? DataMapper will let you write readable and natural Ruby code to access data of all types. Your legacy models will be a delight to work with. Use them directly in your web app if you like!

Technically speaking, DataMapper allows for different modeling tasks than ActiveRecord or Sequel. DataMapper is highly customizeable, allowing users to override and redefine naming conventions, key and field mappings at whatever granularity users may desire (from individual fields all the way up to global table mapping). This ability coupled with DataMapper's Property API allows users to extract, and more importantly, insert data into legacy databases in a compact, modularized and reusable manner. DataMapper's Property API allows you to author classes to encapsulate even the oddest assumptions made by past maintainers in their data modeling. DataMapper's configurability lets you cleanly and simply represent these details so that you can write your model code how you want, and plug into larger systems which rely upon a clean Model API.

I will cover how to use these DataMapper APIs to tame legacy data sources, and cover basic DataMapper integration into rails via the dm-rails gem and the ActiveModel API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment