Skip to content

Instantly share code, notes, and snippets.

@jamonholmgren
jamonholmgren / NSObject.rb
Last active December 16, 2015 18:00
RubyMotion - using method_missing to automatically snake_case Obj-C methods.
class NSObject
def method_missing(meth, *args)
obj_c_meth = meth.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
if respond_to?(obj_c_meth)
send obj_c_meth, *args
else
raise NoMethodError.new(meth.to_s)
end
end
end