• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Module, Class, attr_accessor help?

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 290 Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    Chris Fullmer
    last edited by 15 Apr 2011, 21:42

    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

    Lately you've been tan, suspicious for the winter.
    All my Plugins I've written

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 15 Apr 2011, 22:59

      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().

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chris Fullmer
        last edited by 16 Apr 2011, 05:24

        Awesome, thanks Dan!

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • D Offline
          david.
          last edited by 16 Apr 2011, 16:16

          I do it that way all the time.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            2/4
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement