On Wed, Oct 10, 2012 at 6:24 PM, Jeremy Evans <[email protected]>wrote:

> 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
>
>
>
That's a great idea! In the beginning I thought about using a module too,
but I discarded the idea because I thought that Sequel could have something
like an interface, but now I realize that this is Ruby and not Java and the
modules are powerful and flexible!

Thank you!
Joe

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en.

Reply via email to