artichoke_core/top_self.rs
1//! Expose the global context, called [_top self_][topself], to the interpreter.
2//!
3//! [topself]: https://www.sitepoint.com/rubys-top-self-object/
4
5use crate::value::Value;
6
7/// Return a `Value`-wrapped reference to [_top self_][topself].
8///
9/// Top self is the root object that evaled code is executed within. Global
10/// methods, classes, and modules are defined in top self.
11///
12/// [topself]: https://www.sitepoint.com/rubys-top-self-object/
13pub trait TopSelf {
14 /// Concrete [`Value`] type.
15 type Value: Value;
16
17 /// Return a [`Value`]-wrapped reference to "top self".
18 ///
19 /// Top self is the root object that evaled code is executed within. Global
20 /// methods, classes, and modules are defined in top self.
21 fn top_self(&mut self) -> Self::Value;
22}