byroot / activerecord-typedstore

ActiveRecord::Store but with type definition
MIT License
439 stars 57 forks source link

Manage several serialized hash with same key. #7

Closed Yoshyn closed 2 years ago

Yoshyn commented 10 years ago

Hi.

I saw your presentation on ParisRB and i realy like your gem. It will be great if we can manage serialized hash with same key.

Let me explain :

class Data < ActiveRecord::Base
  typed_store :hash1 do |s|
    s.string :field
  end

  typed_store :hash2 do |s|
    s.string :field
  end
end

Data.new.field

The previous code will always search in the second hash the field.

It can be usefull to add something like this :

  typed_store :hashX, prefix: true do |s|
    s.string :field
  end

And after, access to field with something like : Data.new.hashX_field

I just made a commit here : https://github.com/Yoshyn/activerecord-typedstore/commit/cdd0b083bde6989f786e84bfaf2317c481237b32

The code is not realy good and it's only for AR_32. I just made this to unterstand your code and see if it's possible (I am not familiar with github. Does my commit need a pull request in this case?).

What do you thing about the main idea?

byroot commented 10 years ago

I saw your presentation on ParisRB and i realy like your gem

Thanks !

Does my commit need a pull request in this case?

In theory yes, but since, it's just a prototype, and that your idea make perfect sense, don't worry, I'll add the whole feature myself.

Bahanix commented 10 years ago

:+1:

byroot commented 10 years ago

yeah... I should get back on that one.

Yoshyn commented 2 years ago

[Closing some of my old pending issues]