Setting Up Setters


#1

If I have a setter method that needs to manipulate the incoming value
before setting itself, how can I do this without it be self
referencing? In the example below, I’ve defined “start_date=”, so how
do I now save a value to start_date?

thx

Ex:
class Event
def start_date=(new_start_date)
self.start_date = new_start_date unless new_start_date >=
start_date
end
end


#2

On 7 May 2009, at 13:55, rapdup removed_email_address@domain.invalid wrote:

If I have a setter method that needs to manipulate the incoming value
before setting itself, how can I do this without it be self
referencing? In the example below, I’ve defined “start_date=”, so how
do I now save a value to start_date?

Look for write_attribute

Fred