On Dec 1, 2007 2:35 PM, Aman Gupta <[EMAIL PROTECTED]> wrote:
>
> So here's a simple Orderable I started working on: 
> http://pastie.caboo.se/123976
>
> It works well and good, except I can't figure out a good way to accept
> and store options given to is.. For example, if instead of the
> default :position field, my table instead had a :pos, I want to be
> able to do:
>
> is :Orderable, :field => :pos

I've attached Og's Orderable and it's spec file in case it gives any ideas.

Mark

> I can access opts[:field] in my Sequel::Plugin::Orderable.setup, but
> where do I store it so its available in all instances of the class?
>
>   Aman Gupta
>
> On Nov 30, 9:51 pm, "Mark Van De Vyver" <[EMAIL PROTECTED]> wrote:
> > On Dec 1, 2007 11:07 AM, Mark Van De Vyver <[EMAIL PROTECTED]> wrote:
>
> >
> >
> >
> > > On Dec 1, 2007 10:46 AM, Aman Gupta <[EMAIL PROTECTED]> wrote:
> >
> > > > is Sequel::Plugin::List would work, otherwise ruby won't recognize
> > > > List as a valid class. Alternatively, we could do is :List and have a
> >
> > > That's right. Apologies for the sloppy post.  For lazy reasons, is
> > > Sequel::<plugin> has some appeal, but there maybe aclash with current
> > > or planned modules.
> >
> > > Also, the is <module> has the advantage of indicating more clearly
> > > what is going on, uninitiated might wonder/imagine how 'is_a_list'
> > > differs from 'is_orderable'...
> >
> > > > def is(plugin)
> > > >   begin
> > > >     include Sequel::Plugin.get_const(plugin)
> > > >   rescue
> > > >     require('sequel/plugin/'+plugin.downcase) ? retry : raise
> > > >   end
> > > > end
> >
> > That seems best :)
> >
> > Mark
> >
> > > wouldn't 'alias_method :is, :include' work?  I'll look to see if there
> > > are any gothas.
> >
> > > Mark
> >
> > > >   Aman Gupta
> >
> > > > On Nov 30, 6:42 pm, "Mark Van De Vyver" <[EMAIL PROTECTED]> wrote:
> > > > > Hi Devs,
> > > > > I've followed this with some interest.  I'm not a contributor (just
> > > > > yet - still wrestling with Og)
> > > > > Just one observation/question...
> >
> > > > > <snip>
> >
> > > > > > Sounds great! One question though: how are plugins going to be
> > > > > > installed? are they going to be bundled all together? We also need a
> > > > > > way to load plugins on demand.
> >
> > > > > > > And provide cannonical Model methods is_a(), and is() for 
> > > > > > > including
> > > > > > > the module:
> >
> > > > > > > class Item < Sequel::Model(:item)
> > > > > > >   is_a :list
> > > > > > >   is :orderable
> > > > > > > end
> >
> > > > > > I think it would even be nicer like this:
> >
> > > > > > class Item < Sequel::Model(:item)
> > > > > >    is_a_list
> > > > > >    is_orderable
> > > > > > end
> >
> > > > > class Item <Sequel::Model(:item)
> > > > > is List (able?)
> > > > > is Orderable
> > > > > is ...
> > > > > end
> >
> > > > > Reads like std Ruby and is once less quirk to remember.  This is
> > > > > really a taste issue, and you can see coming from Og I have a
> > > > > preference to, where possible, conform to std Ruby expression,
> > > > > obviously here the compromise is to use 'is' rather then 'include',
> > > > > because it reads more naturally.  the other two proposal require
> > > > > parsing and converting before including the module.
> >
> > > > > Has Sequel considered using std Ruby-like syntax where possible?
> >
> > > > > Mark
> >
> > > > > > > And yes this means I am willing to contribute.
> >
> > > > > > You now have commit rights so go ahead!
> >
> > > > > > sharon
> >
>

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

Attachment: orderable.rb
Description: application/ruby

Attachment: orderable.rb
Description: application/ruby

Reply via email to