Skip to content

Instantly share code, notes, and snippets.

@shadoi
Created March 14, 2012 21:37
Show Gist options
  • Save shadoi/2039717 to your computer and use it in GitHub Desktop.
Save shadoi/2039717 to your computer and use it in GitHub Desktop.
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")
@shadoi
Copy link
Author

shadoi commented Mar 14, 2012

Foo can take arbitrary options and ignore things it doesn't allow. Would like to see alternative implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment