Files
2012-02-21 01:15:00 -05:00

1 line
3.1 KiB
JSON

[{"user_id": 34979, "stars": [], "topic_id": 42071, "date_created": 1310738577.786061, "message": "Is there a way to use \"method_missing(...)\" in a module without classes? If not can I create a static class with the same name as a module, within a module so that I can use \"method_missing(...)\"? Thanks. ", "group_id": 109, "id": 1645411}, {"user_id": 1767, "stars": [], "topic_id": 42071, "date_created": 1310767839.6235819, "message": "`method_missing` works for all kinds of objects, so it does for modules and classes, too. Depending on your specific use case you may need to definite it as a module or instance method.", "group_id": 109, "id": 1648827}, {"user_id": 34979, "stars": [], "topic_id": 42071, "date_created": 1310819086.412461, "message": "self.method_missing", "group_id": 109, "id": 1651461}, {"user_id": 34979, "stars": [], "topic_id": 42071, "date_created": 1310819326.943831, "message": "doesn't seem to work in my method", "group_id": 109, "id": 1651472}, {"user_id": 28525, "stars": [], "topic_id": 42071, "date_created": 1310857088.068254, "message": "method_missing isn't a class method, so your code should be def method_missing. Also, make sure you understand how ruby's call chain works. There may be an override lower in the chain that will execute before your module's implementation does.", "group_id": 109, "id": 1654388}, {"user_id": 1516, "stars": [], "topic_id": 42071, "date_created": 1310993853.9010191, "message": "what do you want method_missing to catch? \"Foo.some_method\" or \"class Something; include Foo; end; Something.new.some_method\"?", "group_id": 109, "id": 1662097}, {"user_id": 24926, "stars": [], "topic_id": 42071, "date_created": 1310996810.6225581, "message": "I'm thinking we need to see code; @samjiman can you drop a gist in here that shows when you want method_missing to work that it's not?", "group_id": 109, "id": 1662546}, {"user_id": 1767, "stars": [], "topic_id": 42071, "date_created": 1311075345.079716, "message": "This will do it if you only want it to work for direct calls on `MyModule`: https://gist.github.com/1092043/f271a6bb8ff777bbb1683e5ad2c339fae3ea98f1", "group_id": 109, "id": 1670367}, {"user_id": 1767, "stars": [], "topic_id": 42071, "date_created": 1311076305.923779, "message": "@samjiman Yes, the first, simple solution only works for calls like `MyModule.xyz`", "group_id": 109, "id": 1670409}, {"user_id": 34979, "stars": [], "topic_id": 42071, "date_created": 1311074983.6274879, "message": "@ntalbott: Here you go, I want something like this: https://gist.github.com/1092031 \r\nThanks.", "group_id": 109, "id": 1670358}, {"user_id": 1767, "stars": [], "topic_id": 42071, "date_created": 1311075629.136286, "message": "And this will also work for other modules/classes that are including `MyModule`: https://gist.github.com/1092043/17ff327456a7832254a8be7f6f8fc35af0a44861", "group_id": 109, "id": 1670377}, {"user_id": 34979, "stars": [], "topic_id": 42071, "date_created": 1311076264.9324839, "message": "Thanks, I think the second one is what I need. First one, didn't work for me - that was because I was doing it from another module I think.", "group_id": 109, "id": 1670405}]