Do not use and
or or
in boolean condition, use &&
and ||
. and
and or
are for control flow. Do not use self.
when reading an attribute, you just do not need it. Do not check booleans like this some_thing == true
, some_thing
is trueish enough.
And I prefer to move complex conditions into private methods. That keeps the method that actual does something more readable.
def check(message_type)
call_some_method if valid_message_type?(message_type)
end
private
def valid_message_type?(message_type)
case message_type
when 'reminder' then copy_reminder
when 'rrm' then is_rrm && copy_rrm
when 'alert' then is_rrm && copy_alert
when 'reply' then is_rrm && copy_user_response
end
end