Skip to content

Instantly share code, notes, and snippets.

@mistydemeo
Created June 29, 2013 20:33
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 mistydemeo/7eee7302984d5d515c75 to your computer and use it in GitHub Desktop.
Save mistydemeo/7eee7302984d5d515c75 to your computer and use it in GitHub Desktop.
class OpenStruct
def new_ostruct_member(name)
name = name.to_sym
unless self.respond_to?(name)
class << self; self; end.class_eval do
define_method(name) { @table[name] }
define_method("#{name}=") { |x| modifiable[name] = x }
end
end
name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment