Is it good or bad to chain method in super like in below activerecord(5.1.6) code,
# 'delivery_timings' is a db field attributeclassCountry<ApplicationRecord# expects array of times and converts to string ie. ['08:00-12:00', '14:00-16:00'] to "08:00-12:00,14:00-16:00"defdelivery_timings=(val)returnsuper(val)ifval.blank?super(val.reject(&:blank?).join(','))end# converts string value to array of times ie. "08:00-12:00,14:00-16:00" to ['08:00-12:00', '14:00-16:00']defdelivery_timingsreturnsuperifsuper.blank?super.split(',')endend
Although the code works, I'm smelling on code(may be wrong).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is it good or bad to chain method in super like in below activerecord(5.1.6) code,
Although the code works, I'm smelling on code(may be wrong).