Support of different coders for ActiveRecord::Store. JSON, Marshal, YAML... #5803

Merged
merged 0 commits into from Apr 11, 2012

Projects

None yet

4 participants

Contributor

... and all things that responds to dump and load can be used out of the box.

Nice feature, +1

@carlosantoniodasilva carlosantoniodasilva commented on an outdated diff Apr 11, 2012
activerecord/lib/active_record/store.rb
@@ -29,11 +35,13 @@ module Store
module ClassMethods
def store(store_attribute, options = {})
- serialize store_attribute, Hash
- store_accessor(store_attribute, options[:accessors]) if options.has_key? :accessors
+ coder = options.has_key?(:coder) ? options[:coder] : Hash
carlosantoniodasilva
carlosantoniodasilva Apr 11, 2012 Owner

You could probably use options.fetch(:coder, Hash) here.

@carlosantoniodasilva carlosantoniodasilva commented on an outdated diff Apr 11, 2012
activerecord/lib/active_record/store.rb
end
- def store_accessor(store_attribute, *keys)
+ def store_accessor(store_attribute, *keys, coder)
+ keys = keys.flatten.map(&:to_s) unless coder == Hash
carlosantoniodasilva
carlosantoniodasilva Apr 11, 2012 Owner

Why is that required? Also notice that keys.flatten is also called in the following line.

Contributor
Contributor
kirs commented Apr 11, 2012

Wow! I dreamed of this feature 👍

@Antiarchitect Antiarchitect merged commit 4c1dcb0 into rails:master Apr 11, 2012

@Antiarchitect thanks! I just want to point out that there was no need for a new pull request, you could just amend your commit and push force to your branch, that Github takes care of updating the pull request here. Anyway, no problem with a new pull request, of course :).

Contributor

It was closed automatically when I rolled back my branch and I cannot reopen it even after proper commit in branch.

Ok, I see there's no code anymore, thanks.

Contributor

Just for consistency - new pull request: http://github.com/rails/rails/pull/5807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment