From: Samuel Williams Date: 2012-07-17T00:35:36+09:00 Subject: Providing a object-specific class scope? --047d7b621d0e506f3f04c4f42e7d Content-Type: text/plain; charset=ISO-8859-1 Is it possible to do something like this with Ruby? #!/usr/bin/env ruby class Scope def hello_world puts "Hello World" end end scope = Scope.new transaction = class << scope; self; end; # Without making Scope#hello_world a class method, can we make this work somehow? eval "hello_world", transaction.send(:binding) The idea would be to provide the ability to write something along the lines of transaction.send(:include, MyModule) without affecting the original instance of scope, while still providing access to all methods. Kind regards, Samuel --047d7b621d0e506f3f04c4f42e7d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Is it possible to do something like this with Ruby?

#!/usr/bi= n/env ruby

class Scope
def = hello_world
puts "Hello World"
end
end

scope =3D Scope.new

transaction =3D class <= < scope; self; end;

# Without making Scope#hello_world a class method, can we make th= is work somehow?
eval "hello_world", transaction.send(:binding)

The idea would be to provide the ability to write= something along the lines of transaction.send(:include, MyModule) without = affecting the original instance of scope, while still providing access to a= ll methods.

Kind regards,
Samuel
--047d7b621d0e506f3f04c4f42e7d--