Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
Module, Class, attr_accessor help?
-
I see attr_accessor as being listed under the module class, are there any pitfalls of using it in a class like this:
module AWESOME_MODULE class AWESOME_MODULE;;Cool_class attr_accessor(;color) end end class_object = AWESOME_MODULE;;Cool_class.new class_object.color= "red"I would like to do that, is it considered standard operating procedure? Or is that bad in any way? I was a little confused by the attr_accessor being a method of the module class, instead of the Class class (or something like that).
So, any thoughts on this? Good, bad, ugly? Thanks,
Chris
-
Yes it's fine and also standard ops.
class Class is a subclass of class Module, so inherits the attr_... methods.
The reason they are defined in class Module is so they can be written as Mixin-Modules, that are mixed into classes using include() and extend().
-
Awesome, thanks Dan!
-
I do it that way all the time.
Advertisement