about summary refs log tree commit homepage
path: root/mahoro.c
diff options
context:
space:
mode:
Diffstat (limited to 'mahoro.c')
-rw-r--r--mahoro.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mahoro.c b/mahoro.c
index 1548a76..1c0b992 100644
--- a/mahoro.c
+++ b/mahoro.c
@@ -18,6 +18,7 @@
 
 static VALUE cMahoro;
 static VALUE eMahoroError;
+static ID id_to_path;
 
 struct nogvl_args {
         magic_t cookie;
@@ -178,6 +179,11 @@ mahoro_file(self, path)
         struct nogvl_args args;
 
         args.cookie = (magic_t)DATA_PTR(self);
+
+        /* Pathname objects may be transformed via #to_path */
+        if (rb_respond_to(path, id_to_path))
+                path = rb_funcall(path, id_to_path, 0);
+
         args.as.path = StringValueCStr(path);
 
         if(!(msg = NOGVL(nogvl_file, &args, RUBY_UBF_IO, NULL))) {
@@ -598,6 +604,7 @@ void Init_mahoro(void)
         rb_define_singleton_method(cMahoro, "compile", mahoro_s_compile, 1);
         rb_define_method(cMahoro, "compile", mahoro_compile, 1);
         rb_define_method(cMahoro, "load", mahoro_load, 1);
+        id_to_path = rb_intern("to_path");
 }
 
 /* arch-tag: mahoro */