On Apr 28, 2014, at 19:55 , Jeremy Evans <[email protected]> wrote:
> On Monday, April 28, 2014 5:49:10 PM UTC-7, Snarke wrote:
> > Second, avoid using class variables in ruby, they are almost always a bad
> > idea.
>
> What is my alternative?
>
> Depending on the situation, either a class instance variable with a class
> accessor method or a constant.
I was afraid you were going to say that. I read quite a bit of Q&As dealing
with class variables when trying to figure out how to best code that module,
and, frankly, I'm still completely in the dark as to what exactly "class
instance variable" is even supposed to mean. The whole 'meta' design thing is
mental quicksand, and I haven't found a good explanation yet, although this has
all mostly just been increased pressure for me to actually open up and read my
copy of Ruby Metaprogramming. :)
However, I started working on folding Postgres's hstore into my models. It took
me a bit to figure out how to get it all lined up. (First do the
'Sequel.extension(:pg_hstore, :pg_hstore_ops)' call, then define DB, *then* do
'DB.extension :pg_hstore'. Aha!)
I created a new column called 'properties' of type hstore in Postgres. And,
well, good grief.
My old way, with separate [model]properties table and my module:
Model.first.properties[:key]=value
New way, with 'properties' hstore column and Sequel extensions, but no new code
beyond that:
Model.first.properties[:key]=value
The only difference is with the new way, I have to .save the model instance. My
way did an immediate write through to the database. In retrospect, not writing
through is probably the better way to go.
So, fine. Fine! I can delete all that singing and dancing I posted here.
Between Postgres and you, y'all have already provided all the functionality I
wanted.
My only defense is that the Postgres people went and snuck the whole 'hstore'
thing into an appendix, and did so long after I'd started using Postgres, so I
wasn't keeping a close enough eye on what they were up to with their upgrades.
--
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.