When I implemented an "instance of"/singleton type pattern, RubyMine notified that using class variables were considered bad form.
The only information I came across is that using class variables can make inheritance a bit squirrelly. Is there any other reason why the following code would give me problems?
class Settings
  private_class_method :new
  attr_accessor :prop1
  attr_accessor :prop2
  @@instance = nil
  def Settings.instance_of
    @@instance = new unless @@instance
    @@instance
  end
  def initialize
    @prop2 = "random"
  end
end
Also, is there a better way, Ruby-wise, to achieve the same objective to ensure only a single instance?
 
     
     
    