Skip to content

Instantly share code, notes, and snippets.

@kisai
Created August 23, 2014 05:47
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 kisai/e841e2f58faca8cf04c2 to your computer and use it in GitHub Desktop.
Save kisai/e841e2f58faca8cf04c2 to your computer and use it in GitHub Desktop.
Method missing
def method_missing(mid, *args) # :nodoc:
mname = mid.id2name
len = args.length
if mname.chomp!('=') && mid != :[]=
if len != 1
raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
end
modifiable[new_ostruct_member(mname)] = args[0]
elsif len == 0 && mid != :[]
@table[mid]
else
raise NoMethodError, "undefined method `#{mid}' for #{self}", caller(1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment