Skip to content

Instantly share code, notes, and snippets.

@domkm
Created June 12, 2013 22:54
Show Gist options
  • Save domkm/5769839 to your computer and use it in GitHub Desktop.
Save domkm/5769839 to your computer and use it in GitHub Desktop.
delegate methods to a serialized hash
class Asset < ActiveRecord::Base
def self.data_delegate(*methods)
methods.each do |method|
define_method(method) { data.send "[]", method }
define_method("#{method}=") { |val| data.send "[]=", method, val }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment