Created
March 14, 2012 21:37
-
-
Save shadoi/2039717 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
class Foo | |
attr_accessor :blah | |
def initialize(options={}) | |
options.each {|k,v| self.__send__("#{k}=", v) if self.respond_to?(k.to_sym)} | |
end | |
end | |
foo = Foo.new(:blah => "test", :blargh => "stuff") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Foo can take arbitrary options and ignore things it doesn't allow. Would like to see alternative implementations.