0

One of classes in an application is grown too much and I would like to group it's methods in some way.

One of ways could be to split Ruby class source into multiple files.

Ruby has a native mechanism to do this called mixins, but mixins are just isolated pieces of code which could be linked to any class. Therefore here is the question:

What is a drawback of working from mixins with instance-wide variables (for example @socket in my case)? Can mixins freely work with these variables?

1 Answer 1

1

Since ruby's variables are not declared, but are implicit, and ruby as a whole is duck-typed, there is no problem for a class/module to assume that there is a variable names @something, and it will work correctly, as long as it is there.

So the answer to your question is - yes, mixins freely work with shared instance variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.