An alternative is

    def special_selector
      query =      { :$query => selector }
      query[:$readPreference] = read_pref  if read_pref
      query[:$orderby] = sort              if sort
      query[:$hint] = hint                 if hint
      query[:$comment] = comment           if comment
      query[:$snapshot] = snapshot         if snapshot
      query[:$maxScan] = max_scan          if max_scan
      query[:$showDiskLoc] = show_disk_loc if show_disk_loc
      query
    end

but I prefer the previous suggested refactoring, and note that it also avoids multiple evaluations of the values when not nil.