Skip to content

Instantly share code, notes, and snippets.

@collin
Created December 2, 2008 22:41
Show Gist options
  • Select an option

  • Save collin/31298 to your computer and use it in GitHub Desktop.

Select an option

Save collin/31298 to your computer and use it in GitHub Desktop.
module PressMember
TableName = 'press_member'
class DataMapper_
include DataMapper::Resource
storage_names[:default] = TableName
property :id, Serial
property :name
end
class ActiveRecord_ < ActiveRecord::Base
set_table_name TableName
acts_as_authentic
end
def self.[] type
case type
when :dm
DataMapper_
when :ar
ActiveRecord_
end
end
end
>> PressMember::DM.first
~ SELECT `id` FROM `press_member` ORDER BY `id` LIMIT 1
=> nil
>> PressMember::AR.first
=> nil
>> PressMember::AR.create
=> #<PressMember::AR id: 1>
>> PressMember::DM.first
~ SELECT `id` FROM `press_member` ORDER BY `id` LIMIT 1
=> #<PressMember::DM id=1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment