M
me
Say, I have a class:
class Event
attr_accessor :a,
:b,
:c,
:d
def initialize()
end
def validate
# validate all attributes at once here
end
protected
def validate_a
# a can be any number from 1-10 if b = 'Y' and c is blank
end
def validate_b
# b can be 'Y' or 'N'
end
def validate_c
end
def validate_d
end
end
And in method validate, I'd like to iterate through all the attributes
and run their respective validating method. Is there a way for me to
be able to iterate through my list of attr_accessor symbols and
reference their names to know which method to call?
Thanks,
-Al
class Event
attr_accessor :a,
:b,
:c,
:d
def initialize()
end
def validate
# validate all attributes at once here
end
protected
def validate_a
# a can be any number from 1-10 if b = 'Y' and c is blank
end
def validate_b
# b can be 'Y' or 'N'
end
def validate_c
end
def validate_d
end
end
And in method validate, I'd like to iterate through all the attributes
and run their respective validating method. Is there a way for me to
be able to iterate through my list of attr_accessor symbols and
reference their names to know which method to call?
Thanks,
-Al