From 7fb1310ab105fb7a82350bad065ae3b11abe88f0 Mon Sep 17 00:00:00 2001 From: Arish Anwar Date: Sun, 19 Jul 2026 15:34:06 +0000 Subject: [PATCH 1/2] fix ruby undefined issue --- src/cookie.rs | 2 +- src/emulate.rs | 2 +- src/http.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cookie.rs b/src/cookie.rs index 5b9d5cd..4edaa8e 100644 --- a/src/cookie.rs +++ b/src/cookie.rs @@ -41,7 +41,7 @@ impl SameSite { SameSite::Lax => "lax", SameSite::None => "none", }; - ruby!().to_symbol(name) + Ruby::get().unwrap().to_symbol(name) } } diff --git a/src/emulate.rs b/src/emulate.rs index a977f13..629c7a2 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -228,7 +228,7 @@ impl Platform { Platform::Android => "android", Platform::IOS => "ios", }; - ruby!().to_symbol(name) + Ruby::get().unwrap().to_symbol(name) } } diff --git a/src/http.rs b/src/http.rs index 2a9e5fe..574320a 100644 --- a/src/http.rs +++ b/src/http.rs @@ -57,7 +57,7 @@ impl Method { Method::TRACE => "trace", Method::PATCH => "patch", }; - ruby!().to_symbol(name) + Ruby::get().unwrap().to_symbol(name) } } From 9f278da4c02156a7c954fa2bf6114063a37615cd Mon Sep 17 00:00:00 2001 From: gngpp Date: Tue, 21 Jul 2026 11:32:47 +0800 Subject: [PATCH 2/2] fix(lib): pass Ruby handle to symbol methods --- src/cookie.rs | 6 +++--- src/emulate.rs | 6 +++--- src/http.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cookie.rs b/src/cookie.rs index 4edaa8e..192575f 100644 --- a/src/cookie.rs +++ b/src/cookie.rs @@ -35,13 +35,13 @@ impl SameSite { } /// SameSite attribute as a lowercase Ruby symbol. - pub fn to_sym(&self) -> magnus::Symbol { - let name = match self { + pub fn to_sym(ruby: &Ruby, rb_self: &Self) -> magnus::Symbol { + let name = match *rb_self { SameSite::Strict => "strict", SameSite::Lax => "lax", SameSite::None => "none", }; - Ruby::get().unwrap().to_symbol(name) + ruby.to_symbol(name) } } diff --git a/src/emulate.rs b/src/emulate.rs index 629c7a2..8feaa1f 100644 --- a/src/emulate.rs +++ b/src/emulate.rs @@ -220,15 +220,15 @@ impl Platform { self.into_ffi().inspect() } - pub fn to_sym(&self) -> magnus::Symbol { - let name = match self { + pub fn to_sym(ruby: &Ruby, rb_self: &Self) -> magnus::Symbol { + let name = match *rb_self { Platform::Windows => "windows", Platform::MacOS => "macos", Platform::Linux => "linux", Platform::Android => "android", Platform::IOS => "ios", }; - Ruby::get().unwrap().to_symbol(name) + ruby.to_symbol(name) } } diff --git a/src/http.rs b/src/http.rs index 574320a..8d63a12 100644 --- a/src/http.rs +++ b/src/http.rs @@ -46,8 +46,8 @@ impl Method { /// HTTP method as a lowercase Ruby symbol. #[inline] - pub fn to_sym(&self) -> magnus::Symbol { - let name = match self { + pub fn to_sym(ruby: &Ruby, rb_self: &Self) -> magnus::Symbol { + let name = match *rb_self { Method::GET => "get", Method::HEAD => "head", Method::POST => "post", @@ -57,7 +57,7 @@ impl Method { Method::TRACE => "trace", Method::PATCH => "patch", }; - Ruby::get().unwrap().to_symbol(name) + ruby.to_symbol(name) } }