Instance variable access from 1 module to another module

I have 2 modules,each having 1 class which contains instance variables &
methods.
I want to access instance variables of 1 class from another class of
another module without calling method.

Please help.

There’s a reason you use methods to access a Class’ state. If you tamper
directly with the internals then any modification to the internals of
that Class will have an adverse effect on your Module.

Having said that, you should be able to call instance_variable_get on
the class instance, passing the name of the instance variable as an
argument.

On Mon, Nov 25, 2013 at 10:52 AM, Joel P. [email protected]
wrote:

There’s a reason you use methods to access a Class’ state. If you tamper
directly with the internals then any modification to the internals of
that Class will have an adverse effect on your Module.

Even worse: that separation is exactly what OO is all about:
information hiding and separation of concerns.

Having said that, you should be able to call instance_variable_get on
the class instance, passing the name of the instance variable as an
argument.

That’s a method call as well. He said

I want to access instance variables of 1 class from another class of
another module without calling method.

Well, the answer to that is: there is no way. :slight_smile: (Or do you know one
without a method call?)

Cheers

robert

Well, I was assuming he meant without a method defined explicitly within
that class :slight_smile:

On Mon, Nov 25, 2013 at 11:19 AM, Joel P. [email protected]
wrote:

Well, I was assuming he meant without a method defined explicitly within
that class :slight_smile:

But you have to agree that this is not what he wrote. :slight_smile: That’s a
nice little example which highlights the important parts of
requirements gathering…

Kind regards

robert

If he were a client, I’d have hammered out the link between technical
and layman terminology, certainly!