Skip to content

Instantly share code, notes, and snippets.

@domkm
Created June 12, 2013 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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