代码应如下所示:
def bring_into_scope(module)
#here the caller of the method should get methods from +module+
end
class Bar
def bar_method
#do stuff
end
end
class Foo
def initialize(bar)
bring_into_scope(bar)
bar_method
end
end
我需要功能因为我想编写一个内联防锈代码的库,所以应该能够编写:
class RustAndRuby
def ruby_method; end
#this should make all fn's in the rust code available in RustAndRuby
Rust.code {
"String with rust code..."
}
end
红宝石可以吗? (如果您需要更多信息,请随时询问!)