You could try the following:
module BookModel
def self.included(base)
base.send :property, :id, String, :key => true, :field =>
'book_id'
base.send :property, :title, String
base.send :property, :title_long, String
base.send :property, :isbn, String
base.send :property, :author, String, :field =>
'authors_text'
end
end
class Book
include BookModel
end
regards
Senny
On 24 Nov., 11:30, Geoff Smith <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I don't suppose anyone could give me a pointer on how to create a
> resource mixin. I've tried using dm-is-remixable, but I don't want to
> create extra tables for 1-1 mappings, I just want the mixin fields to
> be added to the target resource. i.e.
>
> module Addressable
> include DataMapper::Resource
>
> property :country, Integer
> property :street, String
> ...
> end
>
> class User
> include DataMapper::Resource
> include Addressable
>
> property :name, String, :nullable => false, :length => (0..100)
> property :dob, Date, :nullable => false
> ...
> end
>
> This doesn't work because when I auto_migrate, the code breaks because
> it was expecting a class for addressable not a module. I've tried
> overriding the necessary methods auto_upgrade! etc but then the mixin
> fields are ignored completely.
>
> Any suggestions?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---