On Wednesday, October 10, 2012 10:58:02 PM UTC+2, JoeLoui wrote: > > Sorry for not being more specific, I tried to be general but I realized > that is difficulting the problem understading. Here it is the > gist<https://gist.github.com/3868059>with the full backtraces for both > examples. > > In my Foo class I'm using something like > this<https://gist.github.com/3868152>. > The reason I'm doing this it's because I don't want to repeat this code in > Bar1 and Bar2, and it's worth to mention that Bar1 and Bar2 each has > differents columns but shares the relationship with user (and the > callbacks). I supossed that I could use a sequel model as a some kind of > interface in order to DRYup the code, besides I will never need instantiate > Foo for any reason, but it would be handy sometimes not to care having a > Foo object whether is Bar1 or Bar2. As you correctly guessed I think I'm > using methods which needs a dataset, in what other ways can I make this? >
You can use a plain ruby module with an included/extended hook or plugin to share code between models in this way. See https://gist.github.com/3868477 for an example using a plugin. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/d3-C7nh9kX4J. 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/sequel-talk?hl=en.
