datamapper / dm-is-remixable

dm-is-remixable allow you to create reusable data functionality
http://datamapper.org/
MIT License
13 stars 5 forks source link

remixed model repository remains :default #14

Open 1xch opened 13 years ago

1xch commented 13 years ago

I've just started working with trying to create different repositories, and I haven't been able to get remixed models to inherit the repository, or change the repository from :default

Using this:

https://gist.github.com/1278627

I can specify a repository for the Ticket model, but TicketComments can not be changed from the methods I've tried. The expected behavior should be for remixed models to inherit the repository of the models remixed from, i.e. TicketComments should inherit the repository of Ticket, but this may be my opinion in this case and I can see where it might not always be the case.

I'm probably missing the obvious method, but going through several times from various directions resulted in no change.

1xch commented 13 years ago

So, directions tried:

1) using enhance DataMapper.repository(:newrepo) (no effect) def self.default_repository_name; :newrepo; end (error for the generated model on automigrate: must have at least one property or many to one relationship to be valid) def default_repository_name; :newrepo; end (no effect)

2) module RemixeeClassMethods (no effect) end

3) in the module to be remixed itself (no effect)

I guess I'm still not 100% about how repository get manipulated, but the methods I've tried tried just get ignored for the remixed model, the same methods that will work for the model doing the remixing.

1xch commented 13 years ago

I'm not sure I'm missing something (probably), but if this is some functionality that is missing (repository always gets set to :default) there are a number places to think about where to put a method that handles setting the repository for the remixed model: RemixeeClassMethods, within enhance, within the remix method, but I'd just prefer it to be default behavior that gets that can be overridden, remixed models inherit the repository of the model doing the rmixing and if needed overwritten in the 'remix n, :remixables, :repository => :newrepo'