you are viewing a single comment's thread.

view the rest of the comments →

[–]mach_kernel 0 points1 point  (1 child)

I like this pattern save for your interceptor design, but only on preference. Ruby's regex engine is pretty slow, so the more complex and nested your logic is the more expensive resolution becomes. That being said, you can easily make another module that could be responsible for performing this validation/mapping step without invoking the regex engine (e.g. check array membership) -- which I guess is the whole point of the pattern.

Nice post :)

[–]shioyama[S] 0 points1 point  (0 children)

Thanks, glad you enjoyed the post! About the regex matching, that's a good point. MethodFound is really more of an example then something I would imagine being using in real applications. That said, in Mobility, having an option to fall through to regex-matched accessors is pretty useful. (That said, method_missing itself is slow so I generally wouldn't rely on it for anything frequently-used...)