pseudo icon indicating copy to clipboard operation
pseudo copied to clipboard

Ruby – generate attr_accessor for ivars

Open atg opened this issue 8 years ago • 1 comments

Input

class Barney:
  def __init__(self):
    self.status = 'not ok'
barney = Barney()
barney.status = "ok"
print(barney.status)

Output

class Barney
  def initialize
    @status = 'not ok'
  end

end

barney = Barney.new
barney.status = 'ok'
puts barney.status

Error

undefined method status=' for #<Barney:0x007f837084d190 @status="not ok"> (NoMethodError)`

atg avatar Mar 18 '16 20:03 atg

  • [ ] add a AttrAccessMiddleware which analyzes the read/write access to an attribute
  • [ ] render attr_reader , attr_writer or attr_accessor based on the access field

alehander92 avatar Mar 19 '16 07:03 alehander92