On Jul 27, 6:33 pm, "Michael Klishin" <
michael.s.klis...@gmail.com>
wrote:
> I think it would be useful and a good fit for a plugin. Should not be
> too hard to implement, too. So go for it ;)
> --
> MK
I was not familiar with SQL, and I found that it was database
dependent.
Anyway, I have just created a project *dm-mapping* for testing the
thought.
http://github.com/godfat/dm-mapping
Though currently only sqlite3 is supported,
feel free to fork it or use it in somewhere.
(sql codes were borrowed from activerecord 2.1)
Here's the updated thought of usage:
== SYNOPSIS:
require 'dm-core'
# setup first, or dm-mapping can't determine which adapter it should
load up
DataMapper.setup :default, 'sqlite3://db/development.sqlite3'
require 'dm-mapping'
class User
include DataMapper::Resource
mapping /*/
mapping DataMapper::Mapping::All
mapping /_at$/, /^salt_/
mapping :account, :email
mapping *storage_fields
end
DataMapper.repository.storages
# => ['users']
User.storage_fields
# => ['account', 'email', 'created_at', 'salt_first', 'salt_second']
DataMapper.repository.fields('users')
# => ['account', 'email', 'created_at', 'salt_first', 'salt_second']
DataMapper.repository.storages_and_fields
# => {'users' => ['account', 'email', 'created_at', 'salt_first',
'salt_second']}
Thanks for your listening,