Skip to content

Instantly share code, notes, and snippets.

@mdobson
Created July 8, 2012 15:00
Show Gist options
  • Save mdobson/3071299 to your computer and use it in GitHub Desktop.
Save mdobson/3071299 to your computer and use it in GitHub Desktop.
Defining a dynamic singleton method in ruby
class Doc
def initialize(doc)
doc.each do |key, value|
define_singleton_method key, lambda { value }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment