A couple of things about this caught my eye -
> > class Fan < Sequel::Model
> > one_to_many :friends, :class => :Artist, :key => :artist_id
> > end
> 

As someone reading this for the first time you don't really have to infer 
anything from the code above. What is the association name? `friends`. What 
class is that using? `Artist`. How is sequel finding the associated record? 
`artist_id`. It's all right there. 
> > class Fan < Sequel::Model
> > one_to_many :artists, :name => :fans
> > end
> 

Compared to this version we can assume the table and key. But what does `:name` 
imply? Is this the method name? The association name? A field in the database? 
I'm not saying it's impenetrable but it does involve a little more 
foreknowledge to figure out what is going on. Black magic? Rails magic (a 
particularly gnarly form of magic)? Straight up Ruby? Who knows??!?! Help me.
> Basically, I'm leaning against this, so unless I see broad community support 
> for it, I don't plan on adding this feature. My main reason against adding it 
> is that adds yet another option, for the sole purpose of making defining 
> associations very slightly less verbose for many_to_one and many_to_many 
> associations.

In general, I favor not polluting a project with tons of options. I think 
Sequel is amazingly feature-rich and has more options than other Ruby ORMs. I 
also like that the project is flexible enough that you could add this as a 
plugin without much trouble. (The source will show you exactly how to do that. 
Maybe call it super-models? Super-module? hello-my-name-is?) 

I don't see how this change improves the day-to-day usage of your associations. 
It optimizes the line above and that's it. And how often are you writing it? 
Ten times per project? 

Correct me if I'm wrong, but can't you just define another class method which 
refers to the dataset?

```
class Fan
    one_to_many :artists

    def self.fans
        artists_dataset # so you can chain it and be happy!
    end
end
```

Now you can have your cake and eat it too. Yummy, yummy cake.

If the main argument in favor is to control the automagic methods that get 
created then the verbose style should be okay as you only have to put it in one 
place to get the super duper `#add_association`, `#remove_association`, etc 
methods.

(I would advocate defining your API clearly on the models and using the Sequel 
API as internal only.)

Happy Halloween sequelites.

--
Don Morrison
@elskwid



-- 
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