associating to a hash?

I'm setting up my users' profiles as a set of key/value pairs...
where each key/value pair is a row in an associated table, like so:


  The profile_keys themselves are associations to a "profile_keys"
table (yea, way too organized, I know. :wink:

  For some syntax sugar, I've set up some methods on the "profile"
has_many association on the user:

    def [](k)
      return fetch(socialize(k))
    def []=(k, v)
      kk = socialize k
      user = @owner
      if entry = fetch_object(kk)
        entry.value = v
        entry =
          :profile_key => kk, :value => v, :user => user
      return entry
    def socialize(key)
      if key.class == Fixnum
        key = UserProfileKey.find key
      elsif key.class == String or key.class == Symbol
        key = UserProfileKey.find_by_name key.to_s
      return key
    def fetch_object(profile_key)
      result = self.collect { |x| x if x.profile_key == profile_key }
      if v = result.first
        return v
        return nil
    def fetch(profile_key)
      if v = fetch_object(profile_key)
        return v.value
        return nil

  Before I go too much further down this path... I'm *sure* somebody
else out there has set up an associated key/value pair table... is there
some published prior art on this? A plugin perhaps? (If not, the end result
is probably going to be me writing one... :wink: