Skip to content

Instantly share code, notes, and snippets.

@jaredcwhite
Created December 31, 2021 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredcwhite/e6a59e5908ddd761d33afebd8fd34fda to your computer and use it in GitHub Desktop.
Save jaredcwhite/e6a59e5908ddd761d33afebd8fd34fda to your computer and use it in GitHub Desktop.
A Ruby equivalent to JavaScript's Object.assign
Object.class_eval do
def self.assign(obj, options={})
options.each do |k, v|
obj.send("#{k}=", v)
end
obj
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment