Permalink
Browse files

Adds support for urls with pascal casing for underscored method names

Signed-off-by: Jimmy Schementi <jschementi@gmail.com>
  • Loading branch information...
1 parent bbe735d commit e125fd41a93376a868c7d328dee18dee760ed01d @casualjim casualjim committed with Mar 7, 2009
Showing with 11 additions and 5 deletions.
  1. +11 −5 IronRubyMvc/Core/RubyEngine.cs
@@ -114,6 +114,16 @@ public RubyController ConfigureController(RubyClass rubyClass, RequestContext re
return controller;
}
+ public string GetMethodName(object receiver, string message)
+ {
+ var methodNames = Operations.GetMemberNames(receiver);
+
+ if (methodNames.Contains(message.Pascalize())) return message.Pascalize();
+ if (methodNames.Contains(message.Underscore())) return message.Underscore();
+
+ return message;
+ }
+
/// <summary>
/// Calls the method.
/// </summary>
@@ -123,11 +133,7 @@ public RubyController ConfigureController(RubyClass rubyClass, RequestContext re
/// <returns></returns>
public object CallMethod(object receiver, string message, params object[] args)
{
- if (!Operations.ContainsMember(receiver, message) && Operations.ContainsMember(receiver, message.Pascalize()))
- message = message.Pascalize();
- if (!Operations.ContainsMember(receiver, message) && Operations.ContainsMember(receiver, message.Underscore()))
- message = message.Underscore();
- return Operations.InvokeMember(receiver, message, args);
+ return Operations.InvokeMember(receiver, GetMethodName(receiver, message), args);
}

0 comments on commit e125fd4

Please sign in to comment.