Skip to content

Instantly share code, notes, and snippets.

@kml
Created September 9, 2015 10:50
Show Gist options
  • Save kml/27af4a6db7fc3b1495fd to your computer and use it in GitHub Desktop.
Save kml/27af4a6db7fc3b1495fd to your computer and use it in GitHub Desktop.
class ClosedStruct < OpenStruct
# https://github.com/ruby/ruby/blob/trunk/lib/ostruct.rb#L176
def method_missing(mid, *args)
return super if @table.has_key?(mid.to_sym)
raise NoMethodError, "undefined method `#{mid}' for #{self}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment