On Saturday, April 26, 2014 4:50:03 PM UTC-7, Snarke wrote: > > It bugs me to have to call initializeSparse for each use, but as far as I > can figure, modules can’t set class variables, at least not without doing > mysterious meta-programming beyond my grasp. An earlier version of > PropProxy inherited from Hash, but then I have to override all five ways to > set the values, and I still have to reload it every time it’s called in > case the database has been updated elsewhere, so that seemed > overly-complicated. If one wants to do clever hash-y things to the > properties, just call .properties and get the hash.
First, you should make this a plugin. Second, avoid using class variables in ruby, they are almost always a bad idea. Using a plugin's configure method, you get a reference to the model class loading the plugin, which allows you to modify the model in any way you want. Look at the plugins that ship with Sequel for examples. > At some point I might replace the …properties table with a PosgreSQL array > or the hstore datatype. > > Comments? Warnings? Laughter? > Well, the entity attribute value table (EAV) approach is a fairly common way to represent the storage of arbitrary metadata for a related row in another table. It works OK for simple things, but quickly becomes problematic if you want more complex querying. If you only plan to support PostgreSQL, I would definitely switch to the hstore approach. It will be faster, easier to query, and simpler to implement. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
