Created
October 18, 2011 18:29
-
-
Save patmaddox/1296248 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class UserMigration < Migratrix::Migration | |
| set_extractor :mongo, :db => "funky" | |
| end | |
| class MongoExtractor | |
| def do_the_work | |
| end | |
| class Migratrix::Migration | |
| def self.mongo | |
| MongoExtractor.new | |
| end | |
| end | |
| Migratrix.register_extractor :mongo, MongoExtractor | |
| class Migratix | |
| # basic method definition | |
| def self.register_extractor(key, klass) | |
| define_method(key) { klass.new } | |
| end | |
| def extract | |
| send(extractor_key).perform | |
| end | |
| # registry lookup | |
| def self.register_extractor(key, klass) | |
| registry[key] = klass | |
| end | |
| def extractor | |
| registry[extractor_key].new(extractor_options) | |
| end | |
| def extract | |
| extractor.perform | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment