I'm trying to figure out a way for a case
statement to take into account two parameters passed in from a regex.
My regex example is:
When (/^(?:a|an|the) (RoleA|RoleB)
attempts to access a (New|Updated) Record$/)
do |role_type, record_type|
.
I have a case
statement that only accounts for role type right now, but how do I also have the case portion account for role_type
and record_type
?
My goal is to test that Role A is directed to a different set of endpoints when the record type is "New" or "Updated" and I want Role B to be directed to another set of endpoints when passing in "New" and "Updated". If they were being passed into the same endpoints, then a case statement for record_type
only would suffice.
What I have right now is:
case record_type
when 'New'
<do something>
when 'Updated'
<do something>
end
I'd like to switch the behavior based on what the role is. This didn't work:
case record_type && role_type == 'RoleA'
when 'New'
<do something>
when 'Updated'
<do something>
end
case record_type && role_type == 'RoleB'
when 'New'
<do something>
when 'Updated'
<do something>
end
This code is skipped over and I'm assuming that Ruby is confused about which statement to use.