On Jul 14, 2:38 pm, cult hero <[email protected]> wrote: > > def username=(u) > > super(u.downcase) > > end > > This is where my ignorance of Ruby and Sequel kicked in. I didn't > think those were part of the super class. I thought they were built > into the class I was working with itself. Meta-programming, while very > cool, is one of the harder points of Ruby to grok.
Technically, the methods are added to a module that is included in the class, so they aren't part of the superclass either. Attribute accessors and association methods that Sequel creates for you are added this way specifically to allow users the ability to override the methods and call super instead of having to alias. In general, Sequel allows you to override any model class or instance method and use super to get the default behavior, since even the basic class and instance methods are actually defined in modules included in the class, instead of being defined in the class itself. > And in theory I could also do this then: (right?) > > def username=(u) > self[:username] = (u.downcase) > end Yes. That's basically what super will do. > I am finally getting to use Sequel full time on a project and it's an > absolute joy to deal with. I even fire up IRB and do a lot of > manipulation through there rather than GUI apps. It's a really, really > great tool. I hope to become familiar enough with it do more than just > ask questions around here all the time! But in the meantime, let me > just say how killer it is and how surprised I am (and impressed) with > the prompt responses I get here. I'm glad you are finding it useful. :) Jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
