Created
May 24, 2013 21:55
-
-
Save pritchie/5646765 to your computer and use it in GitHub Desktop.
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
module AwesomeResource | |
attr_reader :awesome_attributes | |
def initialize(attributes={}) | |
@awesome_attributes = attributes # AwesomeResource::Attributes.new attributes | |
define_attribute_accessors | |
end | |
private | |
def define_attribute_accessors | |
awesome_attributes.each_key do |k| | |
self.class.send(:define_method, k, Proc.new { @awesome_attributes[k] }) | |
self.class.send(:define_method, "#{k}=", Proc.new { |v| @awesome_attributes[k] = v }) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment