Skip to content

Instantly share code, notes, and snippets.

@garrypolley
Created July 16, 2014 12:19
Show Gist options
  • Select an option

  • Save garrypolley/fbc52427cdb70ab6bbd7 to your computer and use it in GitHub Desktop.

Select an option

Save garrypolley/fbc52427cdb70ab6bbd7 to your computer and use it in GitHub Desktop.
Making the world a little crazier with Ruby. This could obviously be more robust.
class DynamicSingletonMethods
def method_missing(meth,*args,&block)
method_string = meth.to_s
if method_string.end_with? '='
method = method_string.split('=')[0]
self.define_singleton_method(method.to_sym) do args[0] end
else
super
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment