Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Extract Part Of Class In Ruby Into Separate Class

DZone's Guide to

Extract Part Of Class In Ruby Into Separate Class

·
Free Resource
When you need to split class into seveal parts...

New file:

  ClassPart = proc do
    
  
   
  end

  

Original class:

  class MainClass
    class_eval &ClassPart
    ...
  end


I used this approach to create a recycled bin: when i find some functionality not very valuable i move it to the 'recycled bin' part of class. i keep it there for a while. then i delete it altogether from code.
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}