Created
June 12, 2013 22:54
-
-
Save domkm/5769839 to your computer and use it in GitHub Desktop.
delegate methods to a serialized hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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