How to refactor this function to solve cyclomatic issue? I'm trying to fix this error on codeclimate


  Cyclomatic complexity for resource_icon is too high. [7/6]


What is the best way to refactor this function?

def resource_icon(resource)
    case resource.to_sym
    when :locations
      'fa-building'
    when :monitored_places
      'fa-globe'
    when :attendances
      'fa fa-bicycle'
    when :gym_distribuitions
      'fa fa-users'
    when :ranking_activities
      'fa fa-list-ol'
    when :attendance_by_group_class_trainers
      'fa fa-graduation-cap'
    else
      'fa-diamond'
    end
  end
You could try using a hash that maps "locations" to "fa-building", "monitored_places" to "fa-globe", and so on, with a default value of "fa-diamond".