Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created October 18, 2011 18:29
Show Gist options
  • Select an option

  • Save patmaddox/1296248 to your computer and use it in GitHub Desktop.

Select an option

Save patmaddox/1296248 to your computer and use it in GitHub Desktop.
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