class User < ActiveRecord::Base
def birthdate=(value)
# do something with value
super(value)
end
end
Overriding
Django
class User(models.Model):
_birthdate = models.DateField(db_column="birthdate")
@property
def birthdate(self):
return self._birthdate
@birthdate.setter
def birthdate(self, value):
# do something with value
self._birthdate = value
self(less)
class User:
def __init__(name, email): # self is missing
self.name = name
self.email = email
>>> User(name='Rose Kolodny', email='rose-k@sprawl.net')
Traceback (most recent call last):
# ...
TypeError: __init__() got multiple values for argument 'name'