From: David Masover Date: 2010-03-06T13:39:28+09:00 Subject: Re: "Self Organizing Record" Idea On Friday 05 March 2010 07:30:08 pm thunk wrote: > (and the real question on my mind lately...) > > I'm using Class instances directly as "records" and intend to use > CouchDB (or another "document" base) I'd suggest Riak, but I haven't used any so far. > to pull them up when the system > gets larger. Wait, Class instances? ...why? I really don't understand this. Why would you create a brand-new class for each record? I can understand creating a brand-new _object_ and extending it, but a class? > 1. a new instance method might be added to each class dynamically and/ > or new instance data might be added to the class. Again, it makes NO sense to create a new class for this. Let's talk actual code. Are you really thinking something like this: klass = Class.new klass.send :define_method, :foo do # ... end If so, do this instead: require 'metaid' object = Object.new object.meta_eval do define_method :foo do # ... end end > 2. the object is "marshaled" out with the new methods/variables/data Nope, marshal can't save methods -- or code blocks, as I understand it. You'd have to store those methods as strings and run them with 'eval', which seems tricky and dangerous. > and whoalla... the class will be "corrected" without being edited > directly. What do you mean "corrected"?